$f$ is discontinuous. Find topological conditions that there exists a continuous $g$ st. $f(x)\geq0\iff g(x)\geq 0$. Let $x\in X$ where $X$ is a topological space. It seems like:

Claim 1. For every real-valued function $f$ on $X$, the following conditions are equivalent:

*

*there exists a continuous real-valued function $g$ on $X$ s.t. $$f(x)\geq0 \iff g(x)\geq0.$$

*The set $\{x\in X|f(x)\geq0\}$ is closed.


Is any additional topological assumption needed on $X$? Is second countable T2 topology enough to let Claim 1 hold?
For example, if $X$ is further assumed to be a metric space, then Claim 1 clearly hold by constructing $g(x)=d(x,A)$ where $f(A)< 0$. The distance function must be continuous.

We can write your statements in a more compact way like this:

Let $X$ be a topological space and $f:X\to \mathbb{R}$ a function. Then consider the following two statements:

*

*There exists a continuous $g:X\to\mathbb{R}$ such that $f^{-1}([0,\infty))=g^{-1}([0,\infty))$.

*$f^{-1}([0,\infty))$ is closed.


It is almost trivial that 1 always implies 2.
Now if $X$ is perfectly normal then "$2\Rightarrow 1$" holds. Because in such situation, for a closed subset $A=f^{-1}([0,\infty))$ and some point $B=\{x\}$, $x\not\in A$ we can strictly separate them by taking $g(A)=0$ and $g(B)=-1$ for $g:X\to[-1,0]$.
On the other hand if "$2\Rightarrow 1$" holds then $X$ is perfectly normal. Because given any closed subset $A$ we have a continuous function $f$ such that $f^{-1}([0,\infty))=A$ which then we can compose with a retraction $\mathbb{R}\to(-\infty,0]$ and inclusion to get $f^{-1}(0)=A$. We can also compose it with retraction $\mathbb{R}\to[-1,\infty)$ and inclusion to ensure it is bounded. And that means $X$ is perfectly normal (Showing these definitions of 'perfectly normal' spaces are equivalent).
All in all: your claim is equivalent to $X$ being perfectly normal. Note that all metric spaces are perfectly normal Hausdorff.
