If you are considering a situation like that the second image depictes, you might do many simplifications such as taking into account only a perpendicar section to the principal axis of the body - it depends on load distribution and border conditions too-
I you are performing a FE analysis in 3D like your second image suggests, the question is not how you generate your matrices for a specific problem, but rather how to apply boundary conditions and loading to your model to represent the specific torsion you want to analyse. I agree it will change your matrices but the task to perform is not the same.
Depending on what you want to study, you can consider restricting the movements of the extreme faces of your rod, and apply either moments or rotational displacements to them.
You can also consider generating multiple point constraints to link each of the extreme faces to single master points accurately placed on the rotation axis.