The following result is due to Asplund [A, p.235].

>**Theorem.** If $\varnothing\neq E\subset\mathbb{R}^n$ is closed, and $d(x)=\operatorname{dist}(x,E)$, then $f:\mathbb{R}^n\to\mathbb{R}$ defined by 
$f(x)=|x|^2-d(x)^2$ is convex. 

That means $d^2$ has in some sense the same regularity properties as a convex function and that translates into properties of the distance function. The proof of the above result is very easy, but clever.

We have
$$
f(x)=|x|^2-\inf_{y\in E}|x-y|^2=|x|^2+\sup_{y\in E}(-|x-y|^2)=\sup_{y\in E} \big(2\langle x,y\rangle -|y|^2\big).
$$
Therefore,
$f$ is a supremum of a family of affine functions,
and hence it is convex.



**[A] Asplund, E.:**
Cebyvsev sets in Hilbert space.
*Trans. Amer. Math. Soc.* 144 (1969), 235-240.