The answer is that, yes, a smooth, flat solution exists when $g$ is smooth and flat.
Here is how to do it: I'll first do the case that $g$ is even, i.e., $g(-p,-q)=g(p,q)$ and, for convenience, I'll assume that $g$ is defined on the entire $pq$-plane. (The reader can work out the locally defined case.)
Let $(u,v) = (p^2-q^2,2pq)$, and note that there is a (unique) function $\bar g$ on the $uv$-plane such that $g(p,q) = \bar g(u,v)$ and that $\bar g$ is smooth and flat at $(u,v)=(0,0)$. I will look for a solution $f(p,q) = \bar f(u,v)$. By the Chain Rule, the above equation then becomes $$ 2\sqrt{u^2{+}v^2} \, \frac{\partial \bar f}{\partial u} = \bar g, $$ so $$ \frac{\partial \bar f}{\partial u}(u,v) = \frac{\bar g(u,v)}{2\sqrt{u^2{+}v^2}}. $$ The right hand side is smooth and flat at $(u,v) = (0,0)$, so one has a solution in the form $$ \bar f(u,v) = \int_0^u \frac{g(t,v)}{2\sqrt{t^2{+}v^2}}\,\mathrm{d}t\,. $$ This $\bar f$ is flat and gives a solution to the problem.
In the general case, one can write $g = g_0 + g_1$, where $g_0$ is even and $g_1$ is odd, i.e., $g_1(-p,-q) = -g_1(p,q)$. So, to finish, one only needs to solve the case when $g$ is odd. This can be done by using the above solution on the half-planes $p>0$ and $p<0$ and being a little careful about the matching. However, the right way to think about it in the odd case is that $\bar g$ is actually a section of a nontrivial flat line bundle over the punctured $uv$-plane, and the above integral is then taken using parallel translation in the flat line bundle along segements of the form $\sigma(t) = (tu,v)$ for $0\le t\le 1$.
For the local problem, one just assumes that $g$ is defined on an open neighborhood defined by $|p^2+q^2|<\epsilon^2$ for some $\epsilon>0$ and the line integrals in the formula will then still work.