You can use the following
Lemma:
Let $u'$ be the weak derivative of $u$ on $(a,b)$. Then for all intervals $(\alpha, \beta) \subset (a,b)$ it holds that $u'|_{(\alpha, \beta)}$ is also the weak derivative of $u|_{(\alpha, \beta)}$ on $(\alpha, \beta)$.
Proof.
Let $(\alpha, \beta) \subset (a,b)$ and $\phi \in \mathcal{C}_{\text{c}}^{\infty}(\alpha, \beta)$ and define the trivial extension of $\phi$ by $\tilde{\phi} \in \mathcal{C}_{\text{c}}^{\infty}(a,b)$.
Then, we conclude
\begin{equation*}
\int_{\alpha}^{\beta} u(x) \phi'(x) dx
= \int_{a}^{b} u(x) \tilde{\phi}'(x) dx
= - \int_{a}^{b} u'(x) \tilde{\phi}(x) dx
= - \int_{\alpha}^{\beta} u'(x) \phi(x) dx,
\end{equation*}
which implies the proposition.$\ \square$
Back to your question:
This implies, as you rightly point out, that the only candidate for the weak derivative of your function has to be
\begin{equation*}
v(x) = \begin{cases}
0, & \text{if } x \in (0,1), \\
0, & \text{if } x \in (1, 2)
\end{cases}
\end{equation*}
If $v$ is the weak derivative of $u$, for all test functions $\phi \in \mathcal{C}_{\text{c}}^{\infty}(0,2)$ the following has to hold:
\begin{equation*}
\int_{0}^{2} u(x) \phi'(x) dx
= - \int_{0}^{2} v(x) \phi(x) dx.
\end{equation*}
Now,
\begin{equation*}
\int_{0}^{2} f(x) \phi'(x)
= \int_{0}^{1} \phi'(x)
= \phi(1) - \phi(0)
= \phi(1)
\neq 0
= - \int_{0}^{2} v(x) \phi(x).
\end{equation*}
for all test functions with $\phi(1) \neq 0$, which I'm sure you believe exist.
Therefore, your function is not weakly differentiable.