I am looking for an example showingthat a function $f$ which is $C^\infty$ on a submanifold $N$ of $M$, but it cannot be written as the restriction of a $C^\infty$function on $M$.

You can take $M = \{ z \in \mathbb{C} \colon z=1\}$, $N = M \setminus \{1\}$ and $f(e^{i\varphi}) = \varphi$. 

