Let $E=L^2(X,\mu)$ and $g\in L^{\infty}(X)$ be such that $g(x)\geq 0$ for all $x\in X$.
Consider the multiplication operator $M_g(f)=fg$ for all $f\in L^2(X,\mu)$.
Since $g(x)\geq 0$ for all $x\in X$, then $M_g\geq0$ (i.e. $M_g$ is self-adjoint and $\langle M_g(f),f\rangle\geq 0$ for all $f\in L^2(X,\mu)$.
I want to calculate the Moore-Penrose pseudoinverse of $M_g$ (for more details see 2) denoted $M_g^{+}$.
There are three cases (the first two can be seen as the same):
there exists $k>0$ with $g\geq k$ (in which case $M_g^\dagger$ is the usual inverse $M_{1/g}$)
$g=g\,1_E$, and there exists $k>0$ with $g \geq k$ on $E$ (in which case $M_g^\dagger=M_h$, where $h=\frac1g\,1_E$
$g$ takes nonzero values arbitrarily close to zero, in which case the Moore-Penrose inverse does not exist.
If $T$ is the Moore-Penrose inverse of $M_g$, then we have (by definition) $$\tag1 TM_gT=T,\ \ M_gTM_g=M_g, \ \ (TM_g)^*=TM_g,\ \ (M_gT)^*=M_gT. $$ Then, using that $M_g$ is selfadjoint, $$ M_gT=M_g^*T=(M_gTM_g)^*T=M_gT^*M_gT=TM_gT^*M_g=T(M_gTM_g)^*=TM_g^*=TM_g, $$ so $T$ commutes with $M_g$ (and $T^*=T$). It is well-known that then $T=M_f$ for some $f\in L^\infty(X)$.
Now the first two equalities in $(1)$ become $$\tag2 M_{f^2g}=M_f,\ \ M_{fg^2}=M_g. $$ That is, $$\tag3 f^2g=f,\ \ fg^2=g. $$ From the first equation, whenever $f\ne0$ we get $fg=1$; and $fg=1$ when $g\ne0$ from the second equality. So $f=1/g$ whenever $g\ne0$. This leads to the three cases mentioned above.