The title is the question on a problem set our instructor gave us. I have not been able to come up with any example.
The only thing I think is true is that $A$ cannot be a submanifold, otherwise I could find a "tubolar" neighborood and use Tychonoff-like function (like bump functions or similar) to extend my function. Actuallly I think this is only a topological matter, hence $A$ should be a set which does not admit such a neighborood.
I hope someone could provide at least an hint or suggestion
For any $M$ you may take any open and non-closed $A \subset M$. In fact, let $p \in \overline A \setminus A$. Then it suffices to find $F \in C^\infty(M \setminus \{p\})$ such that $\lim_{x\to p} F(x) \to \infty$. Its restriction $f = F\mid_A$ has the same property, thus cannot have an extension to $M$.
To find the desired $F$, we consider an open neigborhood $U$ of $p$ and a smooth chart $\phi : (\mathbb R^n,0) \to (U,p)$. Let $\psi : U \setminus \{p\} \to \mathbb R, \psi(x) = 1/\lVert \phi^{-1}(x) \rVert^2$. Let $K$ be a compact neigborhood of $p$ contained in $U$. Then $\{U, M \setminus K\}$ is an open cover of $M$. Working with a smooth partition of unity for this cover we get $F : M \setminus \{p\} \to \mathbb R$ which agrees with $\psi$ in some pointed neighborhood of $p$.