Recall that one definition of the phrase "$f:D\to \mathbb{R}$ is differentiable at $d\in D$" is that the limit $\displaystyle\lim_{x\to d}\frac{f(x)-f(d)}{x-d}$ exists. We have to unpack this a little bit to get at your question.
The usual definition of a limit of a function $g:D\to\mathbb{R}$ is that $\displaystyle\lim_{x\to d}g(x) = L$ if for all $\varepsilon$-balls $B_R$ centered at $L$ there is a $\delta$-ball $B_D$ centered at $d$ such that $g(B_D-\{d\})\subseteq B_R$.
Finally, remember that an $\alpha$-ball centered at $a$ in $A$ is a set $\{p: d_A(p,a)<\alpha\}$. In our case, we are considering $a=d$ and $A=[-5,5]$, so a $\delta$-ball centered at $d$ is in fact the set $(5-\delta, 5]$.
So, going back through the layers, that means that the phrase "$f:D\to \mathbb{R}$ is differentiable at $5\in [-5,5]$" means that there is some $L$ such that for every set $B_R=(L-\frac12\varepsilon,L+\frac12\varepsilon)$ there exists a set $B_D=(5-\delta,5]$ such that for each $x\in B_D$, the real number $\displaystyle\frac{f(x)-f(5)}{x-5}$ is in $B_R$.
Seeing no reason why such a definition should encounter any difficulties, I would say that a derivative can be defined at the boundary of a metric space. However, we must be careful with this: if we have a function defined on $\mathbb{R}$ and we restrict it's domain to a set $A$ with boundaries, the restriction may have a derivative at a boundary point$-$ this does not imply that the original function has a derivative there, for reasons of two-sidedness that other answerers mentioned.
Briefly, it is possible that for each $\varepsilon$ there exists a set $(5-\delta, 5]$ such that the desired condition holds, but for some $\varepsilon$ there fails to be a set $(5-\delta, 5+\delta)$ where the same condition holds. This seems like it would entail the function doing some silly things at the right of 5, but that's usually how we think of the behavior of non-differentiabile functions anyway, so hopefully it doesn't cause too much strain to imagine. (For a more 'well-behaved' example, consider $|x|$ on the domains $[-1,0]$ versus $[-1,1]$).
As for the second question, I can't give you such a detailed explanation with any surity, but I imagine the answer is yes, and formalism works pretty similar to the proof of Fermat's theorem for stationary points.