I think I solved my own question. Comments about this answer and new answers are welcome.
If $x_1,\ldots,x_n$ are observations in a $N(\mu,\sigma^2)$ population and $\mu$ is unknown, then $$f(x_1,\ldots,x_n|\mu,\sigma^2)=\left(\frac{1}{\sqrt{2\pi\sigma^2}}\right)^ne^{-\frac{n\mu^2}{2\sigma^2}}e^{\frac{\mu}{\sigma^2}\sum_{i=1}^nx_i-\frac{1}{2\sigma^2}\sum_{i=1}^n x_i^2}$$
(this shows that the normal family is a exponential family). As the image of the map $$(\mu,\sigma^2)\in \mathbb{R}\times\mathbb{R}^+\mapsto (\frac{\mu}{\sigma^2},-\frac{1}{2\sigma^2})$$ contains an open set of $\mathbb{R}^2$, by a theorem (for instance, see page 6 here), the statistic $U=(\sum_{i=1}^n X_i,\sum_{i=1}^n X_i^2)$ is sufficient and complete for $(\mu,\sigma^2)$. As $T$ is a function of $U$ and is centered for $\sigma^2$, by Lehmann-Scheffé $T$ is UMVUE for $\sigma^2$.
Now, if $\mu=\mu_0$ is known, $\mu$ does not belong to the parametric space anymore, therefore the "new" density function is
$$f(x_1,\ldots,x_n|\sigma^2)=\left(\frac{1}{\sqrt{2\pi\sigma^2}}\right)^ne^{-\frac{1}{2\sigma^2}\sum_{i=1}^n(x_i-\mu_0)^2}$$(we have a new exponential family). As the image of the map $$\sigma^2\in\mathbb{R}^+\mapsto -\frac{1}{2\sigma^2}$$ contains an open subset of $\mathbb{R}$, our statistic $W$ is sufficient and complete for $\sigma^2$. Since it is in addition centered, $W$ is UMVUE for $\sigma^2$ by Lehmann-Scheffé.