Let $(X,\Sigma,\mu)$ be a measure space with $\mu(X)>0$, and let $f:X \to \mathbb R$ be (Borel- or Lebesgue) measurable. Denote the class of functions a.e equal to $f$ by $[f]$.
Is there a $g\in [f]$ with $\operatorname{im} g=\operatorname{essran} f$ on every measurable set, with $\operatorname{essran} f$ being the essential range of $f$?
No. For instance, let $X=\mathbb{R}$ with Lebesgue measure and let $f$ be the identity function. Supposing such a $g$ exists, let $A=\{x\in\mathbb{R}:g(x)=f(x)\}$, which by assumption has full measure. Pick a point $a\in A$ and let $B=A\setminus\{a\}$. Then $B$ still has full measure, so the essential range of $f$ on $B$ is $\mathbb{R}$. However, $a\not\in g(B)$, since $a\not\in B$ and $g$ is the identity on $B$.