The example
$$
f\left(x,y\right)=\begin{cases}
\frac{1}{\left|x-y\right|}, & x\neq y,\\
0, & x=y
\end{cases}
$$
indeed works. Assume towards a contradiction that we have
$$
f\left(x,y\right)\leq g\left(x\right)+g\left(y\right)
$$
for some function $g$.
Let
$$
M_{n}:=\left\{ x\in\mathbb{R}\,\mid\, g\left(x\right)\leq n\right\} .
$$
Note that $\mathbb{R}=\bigcup_{n\in\mathbb{N}}M_{n}$, so that at
least one of the sets $M_{n}$ is uncountable. As such, it has a point
of accumulation in itself (otherwise, it consists of isolated points
only and thus is countable, see Accumulation points of uncountable sets).
Hence, there is a sequence $\left(x_{m}\right)_{m}$ in $M_{n}$ with
$x_{m}\to x$ for some $x\in M_{n}$ and with $x_{m}\neq x$ for all
$m$. Thus,
$$
\infty\xleftarrow[m\to\infty]{}\frac{1}{\left|x_{m}-x\right|}=f\left(x_{m},x\right)\leq g\left(x_{m}\right)+g\left(x\right)\leq2n,
$$
a contradiction.
EDIT: Note that the property of existence of such a function $g$ as you want to have only depends on the cardinality of the set on which $g$ is defined ($\Bbb{R}$ in your case). If you do not see this, note that $f,g$ are arbitrary functions, so that you can transfer $g$ using a bijection (think about it!).
Thus, for any set of the cardinality of the continuum, there is no such function $g$ in general.
For countable sets, however, the claim is true. To see this, let $f : X\times X \to \Bbb{R}$ with $X$ countable (infinite, otherwise, the claim is trivial). Lets say $X = \Bbb{N}$. Now define (similar to the answer of @jgon)
$$
g(n) := \max \{ 0, \max_{i,j \leq n} f(i,j)\}.
$$
We then have for $n := \max \{x,y\}$
$$
f(x,y) \leq \max_{i,j \leq n} f(i,j) = g(n) \leq g(x) + g(y),
$$
where the last step used that $n = x$ or $n=y$ and $g \geq 0$.
Finally, for continuous functions, the claim also holds as noted in the answer by @jgon.