Pointwise multiplication by unbounded function throws us out of $L^2(\mu)$
Replacing $g$ with $\frac{g\phi}{|\phi|}$ on $X$, which doesn't change the $L^2$ norm of $g$ we can first treat the case $\phi=|\phi| \ge 0$ and then use the above to complete the general case; writing $a_k=\mu(A_k)$, the hypothesis gives $a_k$ non zero for infinitely many $k$; for any $a_k= \infty$, we replace $A_k$ with a subset of finite positive measure $b_k$ which exists by sigma finitness, and make $g$ zero outside that on $A_k$, so we can actually assume $a_k$ finite to start with.
Then for all $k>0$ with $a_k \ne 0$, let $g= \frac{1}{k\sqrt{a_k}}$ on the corresponding $A_k$ and zero everywhere else.
It is obvious that the integral of $g^2$ is finite, being dominated by $\zeta(2)$, while the integral of $(\phi g)^2$ is at least an infinite sum of $1$'s, so infinite.