I'm trying to solve an exercise on path integrals, in which I have to move from a path integral in phase space $$ \int \mathcal{D}q \dfrac{\mathcal{D}p}{\hbar} \exp \left(\dfrac{i}{\hbar} \int dt\ (p\dot{q} - H)\right) $$ to a path integral in configuration space only.
I'm given a hamiltonian quadratic in $p$ but it is not of the form $$ H = \dfrac{p^2}{2m} + V(q). $$ So when I plug it in the integral and do some manipulations, I end up with an expression like $$ \left[ \int \mathcal{D}q \exp \left(\dfrac{i}{\hbar} \int dt\ f(q, \dot{q}) \right)\right] \cdot \left[ \int \dfrac{\mathcal{D}p}{\hbar} \exp \left( -\dfrac{i}{\hbar} \int dt\ g(q) p^2 \right)\right]. $$
So my question is how can I get rid of the integral on $\mathcal{D}p$? When the integral in the second exponential is of the form $$ \exp\left( - \text{constant} \cdot \int dt\ p^2 \right). $$ I usually discretize the phase space, and then solve the corresponding gaussian integrals that result from such discretization. However, in this case I'm not sure how should I deal with the $g(q)$ factor and how does it affect the final result. I was tempted to do some kind of change of variables like $$ p' = \dfrac{p}{\sqrt{g(q)}} \quad\Rightarrow\quad \mathcal{D}p = \sqrt{g(q)} \mathcal{D}p' $$ but I don't know why this sounds somehow illegal to me in path integrals.
I would appreciate any hint on this.