Let's consider a function $u \in W^{1,p}(\Omega)$, where $W^{1,p}(\Omega)$ is the Sobolev Space and $\Omega$ is an open set. When we extend $u$ to $\hat{u}$ like this:
$$\hat{u}(x)=\left\{\begin{matrix} u(x) & in \ \Omega\\ 0 & \quad \quad \ in \ \mathbb{R}^n\setminus\Omega \end{matrix}\right. $$
I know that this extension does not need to be in $W^{1,p}(\mathbb{R}^n)$, but I would like to have some counterexample. Certainly there is no problem in $\hat{u}$ to be in $L^p(\mathbb{R}^n)$ and the (weak) derivative isn't it $\hat{u'}$?
As suggested by daw, take $u(x) = 1$. If you have some regularity of $\Omega$, then $$\int_{\mathbb R^n} u \nabla v \, \mathrm{d}x = \int_{\partial\Omega} \frac\partial{\partial n} v \, \mathrm{d}s$$ for $v \in C_c^\infty(\mathbb R^n)$. The right hand side cannot be written as $\int_{\mathbb{R}^n} w \, v \, \mathrm{d}x$ for some $w \in L^1_{\text{loc}}(\mathbb{R}^n)$. Hence, $u$ does not have a weak derivative on $\mathbb{R}^n$.
(It might be possible to generalize this argument to less regular $\Omega$)