If $f \in H^1(\Omega)$ and either $$f=g \quad\text{a.e.}$$ or $$f=g \quad\text{in $L^2(\Omega)$},$$ is $g \in H^1(\Omega)$?
I think since we identify functions that are equal almost everywhere that this result is true. However it still seems a bit strange to me.
Yes, this statement ist true since $H^1(\Omega)$ is a subspace of $L^2(\Omega)$. Moreover, both conditions, i.e., $f=g$ a.e. in $\Omega$ and $f=g$ in $L^2(\Omega)$, are equivalent by definition, since $L^2(\Omega)$ is constructed as a quotient space by the subspace of functions with $f=0$ a.e.