Suppose I have a function $f:\mathbb{R}^n \times \mathbb{R}^n \rightarrow \mathbb{R}$. Fix a natural number $k$. Under what conditions can I write $$ f(x,y) = [g(x) - g(y)]^{T}[g(x) - g(y)] $$ for some appropriate function $g:\mathbb{R}^n \rightarrow \mathbb{R}^k$?
Necessary conditions are obviously that $f(x,y) \geq 0$, $f(x,x) = 0$ and that $f(x,y) = f(y,x)$, but are these sufficient?
No, there is one more condition: $f(x,y)=f(x,0)+f(y,0)-2\sqrt {f(x,0)f(y,0)}$. This condition and the three conditions you have are necessary and sufficient.