The definition of the Radon-Nykodym derivative $\dfrac{\mathrm dQ}{\mathrm dP}=U$ (your $Z$ being $Z=1/U$) is that, for every event $A$, one should have $Q(A)=\mathbb E_P(U;A)$. When $A=[X\leqslant x]$, this is $Q(X\leqslant x)=\mathbb E_P(U;X\leqslant x)$ hence one looks for some density function $g$ such that, for every $x$, $ \mathbb E_P(U;X\leqslant x)=\displaystyle\int_{-\infty}^xg(t)\mathrm dt. $ In the special case when $U=\varphi(X)$, calling $f_X$ the density of $X$, one gets $ Q(X\leqslant x)=\mathbb E_P(\varphi(X);X\leqslant x)=\displaystyle\int_{-\infty}^x\varphi(t)f_X(t)\mathrm dt, $ hence the function $g=\varphi f_X$ is a density (nonnegative, integrates to $1$) and solves your question.
In the general case, calling $f_{U,X}$ the density of the joint distribution of $(U,X)$, the solution is $ g(x)=\int_{0}^{+\infty} uf_{U,X}(u,x)\mathrm du. $ This specializes to $g=\varphi f_X$ when $U=\varphi(X)$ and, at the other extreme, to $g=f_X$ when $U$ and $X$ are independent. However, these cases are the exception rather than the rule since, in general, $g$ does not involve $f_X$ only but the joint distribution of $(U,X)$.