When working with rigid-body transformations, it is crucial to understand which coordinate frame the transformation is defined in. Further, there are different notations for this, so it is important to know which is in use. Let's assume that $T_b^a$ describes the coordinate axes of frame $b$ with respect to the coordinate axes of frame $a$. (Note that this is the same transformation that transforms data in frame $b$ and expresses it in frame $a$.)
Observe that with this notation, the composition of transformations is clear and follows mnemonic that subscripts and superscripts that are next to each other cancel, as in $T_c^a = T_b^a T^b_c$.
In your case, $T_1$ is really the description of the cube's coordinate frame ($1$) w.r.t the camera's coordinate frame ($C$), written $T_1^C$.
Likewise, $T_2$ describes the base coordinate axes ($2$) w.r.t the camera ($C$), written $T_2^C$.
Now, considering the rotation of the camera, we have the new camera axes ($C'$) w.r.t the original camera:
$$
T_{C'}^C =
\begin{bmatrix} R_z(\frac{\pi}{2}) & 0 \\ 0^\top & 1 \end{bmatrix}
=
\begin{bmatrix}
\cos\frac{\pi}{2} & -\sin\frac{\pi}{2} & 0 & 0 \\
\sin\frac{\pi}{2} & \cos\frac{\pi}{2} & 0 & 0 \\
0&0&1&0 \\
0&0&0&1
\end{bmatrix}.
$$
Having defined all of our transformations, we can now easily calculate our desired quantity, $T_{C'}^2$, which can be composed as
$$
T_{C'}^2 = T_C^2 T_{C'}^C = (T_2^C)^{-1} T_{C'}^C.
$$