We know that, if a function $f,g$ are analytic on a simple connected domain $\Omega\in\mathbb C$ and continuous on $\overline\Omega$, and $|f(z)|=|g(z)|,\forall z\in \Omega$, then $\exists\alpha\in\mathbb R, f(z)=e^{i\alpha}g(z),\forall z$.
This means, an analytic function is uniquely determined up to a constant mutiple by its moduli at every point in $\Omega$.
But what if I reverse the thinking process? Let $F(z):\Omega\to\mathbb R^+_0$ be a continuous function on $\Omega$. Under what circumstances does there exist an analytic function $f(z)$ such that $F(z)=|f(z)|,\forall z$? What is the condition on $F$ for it to be the moduli of a holomorphic function?
This is taken mostly from my and @Martin R’s comments.
Obvious necessary conditions are:
1) $Z = F^{-1}(\{0\})$ is a discrete subset of $\Omega$.
2) For each $w \in Z$, there exists $c \in \mathbb{R}^{+*}$, $m \geq 1$ (the multiplicity) such that $F(z) \tilde c|z-w|^m$ as $z \rightarrow w$.
3) $\ln{F}$ is $\mathscr{C}^2$ on $\Omega’=\Omega \backslash Z$ and harmonic on this set.
Assume now that these conditions are met.
Then, there exists a holomorphic function $g$ on $\Omega$ such that $g$ and $F$ have the same zeroes with the same multiplicities (it is a standard complex-analytic fact, but the proof is a bit long so I will not do it).
Thus, $L=\ln{\frac{F}{|g|}}$ is continuous over $\Omega$, and $\mathscr{C}^2$ and harmonic over $\Omega’$.
Let us prove that it is harmonic on $\Omega$. To this effect, we show first that it satisfies a “weak” mean property on $\Omega$, ie, for each $z \in \Omega$, for all circles $C \subset \Omega$ with sufficiently small radius and center $z$, $L(z)$ is the average of $L$ over $C$.
It is known (because $Z$ is discrete) if $z \in \Omega’$. So we assume $z \in Z$. Thus, there exists $R >0$ such that $\mathcal{B}(z,R) \cap Z =\{z\}$ and $\mathcal{B}(z,R) \subset \Omega$.
Consider $0<a<b<R$, and $K$ the compact submanifold with boundary $\cup_{a \leq r \leq b}{C_r} \subset \Omega’$, where $C_r=\{w,\,|w-z| =r\}$.
Let $\alpha=\frac{\partial L}{\partial x}dy-\frac{\partial L}{\partial y}dx$, by Stokes on $K$, $\int_{C_a}{\alpha}=\int_{C_b}{\alpha}$.
In other words, if $0 < r < R$, $\alpha_r=r\int_0^{2\pi}{\left(\frac{\partial L}{\partial x}(z+re^{iu})\cos{u}+\frac{\partial L}{\partial y}(z+re^{iu})\sin{u}\right)du}$ does not depend on $r$.
Now, $\alpha_r=r\frac{d}{dr}\left(\int_0^{2\pi}{L(r+re^{iu})\,du}\right)$, hence $\int_0^{2\pi}{L(r+re^{iu})\,du}=A\ln{r}+B$ for some $A,B$, for all $0 < r <R$. Taking $r \rightarrow 0$ yields $A=0, B=2\pi L(z)$, what we wanted to show.
Now, consider any small enough circle $C$ ($D$ being the open disk inside) centered at any $z \in \Omega$. There exists (https://en.m.wikipedia.org/wiki/Poisson_kernel) a harmonic function $h$ on $D$ that extends continuously on $C$, the extension being $L_{|C}$. Then $L-h$, on $\overline{D}$, satisfies the weak mean property, and is continuous, therefore its maximum modulus is reached on $C$ (“weak mean property” implies the maximum principle exactly like for the actual mean property). Since $L-h=0$ on $C$, $L=h$ in $D$ and $L$ is harmonic in $D$.
Thus, $L$ is harmonic. Since $\Omega$ is simply connected, $L=Re(g)$ for some holomorphic function $g$, thus $F=|e^g|$.