Based on: Is torque always equal to the derivative of potential energy with respect to rotation angle?
Since we have: $$ \hat{n}_{\theta_i}\cdot\vec{\tau} = -\frac{\partial U}{\partial\theta_i}$$
For $i=1,2,3$ , then you may reconstruct the Torque vector via:
$$ \vec{\tau} = -\sum_{i=1}^3 \frac{\partial U}{\partial\theta_i} \hat{n}_{\theta_i} $$
This is not the gradient, at least not in the usual sense of the word, although it has a very similar form. Most importantly: the angles $\theta_i$ may represent rotations from "shifted" axes, in particular this is true for Euler angles. So it's important to know whether the angles refer to an intrinsic or an extrinsic frame, in order to appropriately determine the $\hat{n}_{\theta_i}$'s.
See this for a lot more related information about rotation mechanics of rigid bodies.