When the torque is applied the shaft twists. The twist gives rise to a reaction torque that opposes the applied torque. This is analogous to a spring stretching when a force is applied.
When we integrate the differential equation along a uniform circular shaft of length $L$ we find that $T=-\frac{JG}{L}\theta$, which is analogous to $F=-kx$. The minus sign indicates T is the restoring torque by the shaft, which is opposite to the applied torque. The torsional stiffness of the shaft is $JG/L$.
We can treat each section of the shaft as a separate spring. The twist $\theta_1$ in the spring on the left will give rise to a restoring torque $T_1$ and similarly for the shaft on the right. For static equilibrium, $T+T_1+T_2=0$. For physical continuity of the shaft, $\theta=\theta_1=\theta_2$.
A few things to be careful about when dealing with torsional shafts: First, sometimes the shaft is not uniform. It may have a sudden change in diameter or it may be tapered. Second, the shafts are coupled through gears, which complicates the analysis. 333
Third, when possible consider JG to be a single quantity. The calculation will often be simpler and easier to check when the J and G are always together. In other words, calculate the value a JG as a single value on the side and plug it into your formula in the end, if the shaft arrangement allows.
Fourth, here is a tip for how to remember the correct formula for the polar moment of inertia. What I remember is there are two similar formulas. One formula is for $I$, the moment of inertia used for circular beams in bending. The other is the polar moment of inertial, used for circular shafts in torsion. One formula is $\pi r^4/2$ and the other is $\pi r^4/4$. The formula for the polar moment of inertia is like $A(x^2+y^2)$ and is twice as much as the other one which is just $Ax^2$ or $Ay^2$. So, the polar moment must be the formula with the 2 in the denominator, because 1/4+1/4=1/2. Or, if one uses diameters, one can remember the denominators are 32 and 64 and then it its easy to know which is used in bending and which in torsion. 333