This construction is somewhat similar to the Martin-Siggia-Rose formalism for writing expectation values over solutions of a stochastic differential equation $$ \dot{p}(t)=f(p,t)+\xi(p,t) $$ with $\xi$ a Gaussian noise with correlation function $$ \mathbb{E}[\xi(p,t)\xi(p',t')]=G(p,t,p',t') $$ as a path integral $$ \mathbb{E}[O[p]]=\int\mathcal{D}p\mathcal{D}q\,O[p]\,e^{-S[p,q]} $$ with action $$ S[q,p]=\int \mathrm{d}t\, q\left(\dot{p}-f(p)\right)+\frac{1}{2}\int \mathrm{d}t\mathrm{d}t'\,G(q(t),t,q(t'),t')q(t)q(t'). $$$$ S[p,q]=\int \mathrm{d}t\, q\left(\dot{p}-f(p)\right)+\frac{1}{2}\int \mathrm{d}t\mathrm{d}t'\,G(q(t),t,q(t'),t')q(t)q(t'). $$ In your situation $G\equiv 0$, so there is no stochastic aspect, and the Lagrangian is just $L=q\dot{p}-qf(p)$, where $p$ is really a generalized position coordinate, whence the Hamiltonian is $$ H=P\dot{p}-L=(P-q)\dot{p}+qf(p) $$ where now $P$ is the conjugate momentum to $p$, and identifying $P=q$ yields your ansatz.
As to a physical interpretation of $q$, I don't think there is an obvious one (particularly since $g(q)$ is arbitrary and influences the evolution of $q$).