If $|f(x)|$ is a measurable function defined on a measurable set $E\subset \mathbb{R}^d$, is $f(x)$ also measurable?
Answer No. Consider the nonmeasurable set $\mathcal{N} \subset [0,1]$, and the function \begin{align*} f(x) = \begin{cases} \quad \phantom{-}1, \quad x \in \mathcal{N} \\ \quad -1, \quad x \in [0,1] \setminus \mathcal{N} \end{cases} \end{align*} Here $g(x) = |f(x)| \equiv 1$ on $[0,1]$ and therefore $g(x) = |f(x)|$ is measurable, since $g^{-1}(1) = \{x \in [0,1]: g(x) <= 1\} = [0,1]$, which is a measurable set. But clearly, $f^{-1}(1) = \mathcal{N}$, which is not measurable.
Please check the validity of my proof.