Is it possible to find non-polynomial functions $f(x)$ and $g(x)$ such that $$\left(\frac{f^2}g\right)'=\frac f{g^2}\quad ?$$ If so, what are some examples of such functions?
This is equivalent to $$2ff'g-f^2g'=f\implies 2f'g-1=fg'$$ provided that $f(x)\ne0$.
For polynomials, if $\deg(f)=m$ and $\deg(g)=n$ then $$\deg(\text{LHS})=m+n-1=\deg(\text{RHS})$$ so it could be possible.
In particular, if $f$ is a constant and $g$ is linear then we find that $$\begin{bmatrix}f(x)\\g(x)\end{bmatrix}=\begin{bmatrix}a\\-\frac1ax+c\end{bmatrix}$$ works for any real constants $a,c$ with $a\ne0$.
To illustrate what's in the comments, let $f(x)=e^x$. Then your differential equation is $e^xg'-2e^xg=-1$. Multiply through by $e^{-3x}$ to get $e^{-2x}g'-2e^{-2x}g=-e^{-3x}$, which is $(e^{-2x}g)'=-e^{-3x}$, so $e^{-2x}g=(1/3)e^{-3x}+C$, or $g=(1/3)e^{-x}+Ce^{2x}$.