Here are some more proofs.
The first proof, similar to what is done here, uses the Hahn-Banach theorem. It works for both real and complex normed spaces. If $x\in M$ with $\|x\|\leq 1$ and $g\in M^{\perp}$ then
\begin{equation}
|f_{0}\vert_{M}(x)| = |f_{0}(x) - g(x)| \leq \|f_{0} - g\|_{E^{\star}} .
\end{equation}
Taking the supremum over all $x\in M$ with $\|x\|\leq 1$, we obtain $\|f_{0}\vert_{M}\|_{M^{\star}} \leq \|f_{0} - g\|_{E^{\star}}$. As $g\in M^{\perp}$ was arbitrary, this shows
\begin{equation}
\|f_{0}\vert_{M}\|_{M^{\star}} \leq \inf\{\|f_{0} - g\|_{E^{\star}} : g\in M^{\perp}\} . \tag{1}
\end{equation}
In order to show the desired result it is sufficient to find some $g_{0}\in M^{\perp}$ such that $\|f_{0} - g_{0}\|_{E^{\star}} = \|f_{0}\vert_{M}\|_{M^{\star}}$. By a Hahn-Banach extension theorem (see Corollary 1.2 of [1]), there is a continuous extension $h_{0}\in E^{\star}$ of $f_{0}\vert_{M}$ such that $\|h_{0}\|_{E^{\star}} = \|f_{0}\vert_{M}\|_{M^{\star}}$. Define $g_{0} := f_{0} - h_{0}$. Since $f_{0}$ and $h_{0}$ agree on $M$ we have $g_{0}\in M^{\perp}$, and because $f_{0} - g_{0} = h_{0}$ we have $\|f_{0} - g_{0}\|_{E^{\star}} = \|h_{0}\|_{E^{\star}} = \|f_{0}\vert_{M}\|_{M^{\star}}$. Combined with $(1)$, we obtain
\begin{equation}
\inf\{\|f_{0} - g\|_{E^{\star}} : g\in M^{\perp}\} \leq \|f_{0} - g_{0}\|_{E^{\star}} = \|f_{0}\vert_{M}\|_{M^{\star}} \leq \inf\{\|f_{0} - g\|_{E^{\star}} : g\in M^{\perp}\}
\end{equation}
and conclude
\begin{equation}
\inf\{\|f_{0} - g\|_{E^{\star}} : g\in M^{\perp}\} = \|f_{0} - g_{0}\|_{E^{\star}} . \tag{2}
\end{equation}
In fact, it turns out there is a one-to-one correspondence between continuous linear functionals $g_{0}\in M^{\perp}$ such that $(2)$ holds and norm-preserving Hahn-Banach extensions of $f_{0} - g_{0}$. See this answer for more details.
The second proof involves lower semicontinuous functions as discussed here. It works for both real and complex normed spaces. We recall (see the beginning of Section 1.4 of [1]) that given a topological space $X$, a function $\varphi\colon X\to (-\infty , \infty ]$ is lower semicontinuous if for all $\lambda\in\mathbb{R}$ the set $\{x\in X : \varphi (x) \leq \lambda\}$ is closed in $X$. We also recall that given a normed space $G$, the weak$^{*}$ topology $\sigma (G^{\star}, G)$ on $G^{\star}$ is defined as the coarsest topology on $G^{\star}$ making for every $x\in G$ the map $\varphi_{x}\colon G^{\star} \to \mathbb{K}$ (where $\mathbb{K}$ is the field over which $G$ is a normed space) defined by $\varphi_{x}(f) := f(x)$ continuous.
Assume without loss of generality $f_{0}\neq 0$, for otherwise we simply take $g_{0} = 0$. Define
\begin{equation}
X := \{g\in M^{\perp} : \|g\| \leq 2 \|f_{0}\|\} .
\end{equation}
We first show
\begin{equation}
\inf\{\|f_{0} - g\| : g\in M^{\perp} \} = \inf\{\|f_{0} - g\| : g\in X \} . \tag{3}
\end{equation}
Since $0\in X$, we clearly have
\begin{equation}
\inf\{\|f_{0} - g\| : g\in M^{\perp} \} \leq \inf\{\|f_{0} - g\| : g\in X \} \leq \|f_{0}\| . \tag{4}
\end{equation}
Conversely, if $g\in X$ we clearly have
\begin{equation}
\inf\{\|f_{0} - g\| : g\in X \} \leq \|f_{0} - g\| . \tag{5}
\end{equation}
If $g\in M^{\perp}\setminus X$ then $\|g\| > 2 \|f_{0}\|$, so by the triangle inequality we have
\begin{equation}
\|f_{0} - g\| \leq \|g\| - \|f_{0}\| < \|f_{0}\| \leq \inf\{\|f_{0} - g\| : g\in X \} . \tag{6}
\end{equation}
Combining $(5)$ and $(6)$, we deduce
\begin{equation}
\inf\{\|f_{0} - g\| : g\in X \} \leq \inf\{\|f_{0} - g\| : g\in M^{\perp} \} . \tag{7}
\end{equation}
We consequently combine $(4)$ and $(7)$ to obtain $(3)$.
Next, we show $X$ is compact with the induced $\sigma (E^{\star}, E)$ topology as a subset of $E^{\star}$. Since
\begin{equation}
M^{\perp} = \bigcap_{x\in M}\{g\in E^{\star} : g(x) = 0\}
\end{equation}
is closed in the $\sigma (E^{\star}, E)$ topology and
\begin{equation}
\{g\in E^{\star} : \|g\| \leq 2 \|f_{0}\| \} \tag{8}
\end{equation}
is compact in the $\sigma (E^{\star}, E)$ topology by the Banach-Alaoglu theorem (see Theorem 3.16 of [1]), hence closed in the $\sigma (E^{\star}, E)$ topology, the intersection
\begin{equation}
X = M^{\perp} \cap \{g\in E^{\star} : \|g\| \leq 2 \|f_{0}\| \}
\end{equation}
is closed in the $\sigma (E^{\star}, E)$ topology. Hence $X$ is a $\sigma (E^{\star}, E)$ closed subset of the $\sigma (E^{\star}, E)$ compact set $(8)$, so it follows that $X$ is a $\sigma (E^{\star}, E)$ compact subset of $E^{\star}$.
Let $\tau$ be the induced topology on $X$ from the $\sigma (E^{\star}, E)$ topology on $E^{\star}$. Then $(X, \tau )$ is a compact Hausdorff topological space, where the topology is Hausdorff because the $\sigma (E^{\star}, E)$ topology on $E^{\star}$ is Hausdorff (see Proposition 3.11 of [1]). Define $\varphi \colon X \to \mathbb{R}$ by $\varphi (g) := \|f_{0} - g\|$. We claim $\varphi \colon (X, \tau ) \to \mathbb{R}$ is lower semicontinuous. Let $\lambda \in \mathbb{R}$. If $\lambda < 0$ then $\{g\in X : \varphi (g) \leq \lambda \} = \emptyset$ is closed in the $ \tau$ topology and if $\lambda = 0$ then $\{g\in X : \varphi (g) \leq \lambda \} = \{f_{0}\}$ is closed in the $\tau$ topology (since $\tau$ is a Hausdorff topology). If $\lambda > 0$ then
\begin{equation}
\begin{aligned}
\{g\in X : \varphi (g) \leq \lambda \} &= X \cap \{g\in E^{\star} : \|f_{0} - g\| \leq \lambda\} \\
&\overset{(9)}{=} X \cap \bigcap_{\substack{x \in E \\ \|x\| \leq 1}} \{g\in E^{\star} : |f_{0}(x) - g(x)| \leq \lambda \} ,
\end{aligned} \tag{10}
\end{equation}
where we used a Hahn-Banach theorem (see Corollary 1.4 of [1]) for $(9)$. As the last set of $(10)$ is an intersection of $\sigma (E^{\star}, E)$ closed sets we deduce that $\{g\in E^{\star} : \varphi (g) \leq \lambda \}$ is $\sigma (E^{\star}, E)$ closed. Hence $\{g\in X : \varphi (g) \leq \lambda \}$ is closed in the $\tau$ topology. This shows that $\varphi \colon (X, \tau ) \to \mathbb{R}$ is lower semicontinuous.
Now lower semicontinuous functions attain their infimum on compact sets (see the beginning of Section 1.4 of [1]), so there exists some $g_{0}\in X$ such that
\begin{equation}
\|f_{0} - g_{0}\| = \varphi (g_{0}) = \inf\{\varphi (g) : g\in X\} . \tag{11}
\end{equation}
Then combining $(11)$ with $(3)$ we obtain $g_{0}\in M^{\perp}$ and
\begin{equation}
\|f_{0} - g_{0}\| = \inf\{\varphi (g) : g\in M^{\perp}\} .
\end{equation}
This completes the proof.
The third proof uses convex conjugate functions. It only works for real normed spaces. We first introduce some definitions below.
Given a nonempty set $K\subseteq E$ we define $I_{K}\colon E\to \{0, \infty \}$ by
\begin{equation}
I_{K}(x) := \begin{cases} 0 & \text{if } x\in K , \\
\infty & \text{if } x\in E\setminus K .
\end{cases}
\end{equation}
Given $\phi \colon E\to (-\infty , \infty ]$, we say $\phi$ is convex if for all $x,y\in E$ and $t\in (0,1)$ we have
\begin{equation}
\phi ((1-t)x + ty) \leq (1-t) \phi (x) + t \phi (y) .
\end{equation}
Given $\phi \colon E\to (-\infty , \infty ]$ where there exists $x\in E$ such that $\phi (x) \neq \infty$ we define $\phi^{\star} \colon E^{\star} \to (-\infty , \infty ]$ by
\begin{equation}
\phi^{\star}(f) := \sup\{f(x) - \phi (x) : x\in E \} .
\end{equation}
Define $\varphi \colon E\to (-\infty , \infty ]$ by $\varphi (x) := f(x) + I_{B_{E}}(x)$ where $B_{E}$ is the closed unit ball of $E$. Also define $\psi \colon E\to (-\infty , \infty ]$ by $\psi (x) := I_{M}(x)$. It is straightforward to check that $\varphi$ and $\psi$ are convex functions, $\varphi (0) = \psi (0) = 0$ and that $\varphi$ is continuous at $0$. We recall the following result which is another formulation of Theorem 1.12 of [1].
Theorem 1. Let $\varphi \colon E\to (-\infty , \infty ]$ and $\psi \colon E\to (-\infty , \infty ]$ be two convex functions. Assume that there is some $x_{0}\in E$ such that $\varphi (x_{0}) \neq \infty$, $\psi (x_{0}) \neq \infty$ and that $\varphi$ is continuous at $x_{0}$. Then $\varphi^{\star}$ and $\psi^{\star}$ are defined and we have
\begin{equation}
\inf_{x\in E} \Big( \varphi (x) + \psi (x) \Big) = - \min_{f\in E^{\star}} \Big( \varphi^{\star}(-f) + \psi^{\star}(f) \Big) .
\end{equation}
Since on any given vector subspace a real-valued linear functional is either zero everywhere or its image is unbounded, we have
\begin{equation}
\sup_{x\in M} f(x) = \begin{cases} 0 & \text{if } f\in M^{\perp} , \\
\infty & \text{if } f\in E^{\star}\setminus M^{\perp} .
\end{cases}
\end{equation}
We then apply the above observation and Theorem 1 to obtain
\begin{align*}
- \|f_{0}\vert_{M}\|_{M^{\star}} &= \inf_{x\in B_{E}\cap M} f_{0}(x) \\
&= \inf_{x\in E} \Big( \varphi (x) + \psi (x) \Big) \\
&= - \min_{f\in E^{\star}} \Big( \varphi^{\star}(-f) + \psi^{\star}(f) \Big) \\
&= - \min_{f\in E^{\star}} \Big[ \sup_{x\in E} \Big( - f(x) - \varphi (x) \Big) + \sup_{x\in E} \Big( f(x) - \psi (x) \Big) \Big] \\
&= - \min_{f\in E^{\star}} \Big[ \sup_{x\in B_{E}} \Big( f_{0}(x) - f(x) \Big) + \sup_{x\in M} f(x) \Big] \\
&= - \min_{f\in M^{\perp}} \|f_{0} - f\|_{E^{\star}} .
\end{align*}
Hence there is some $g_{0}\in M^{\perp}$ such that
\begin{equation}
\|f_{0} - g_{0}\|_{E^{\star}} = \|f_{0}\vert_{M} \|_{M^{\star}} = \inf\{\|f_{0} - g\|_{E^{\star}} : g\in M^{\perp} \} .
\end{equation}
This completes the proof.
[1] Brezis, H., Functional analysis, Sobolev spaces and partial differential equations. Universitext. Springer, New York, 2011.