The torque of force about a line is dependent of the choice of the origin which lies on that line itself.
Torque about any point on the Axis of rotation may be different.
But the projection of net torque on the axis of rotation (which will be responsible for the turning effect of the body) will be same.
Eg:- AA' is an axis about which the body is free to rotate. Force F is into the plane. The perpendicular distance of F from axis is 4 units. So torque about line AA' will be r x F = 40
Same situation but this time I am choosing a different point on the axis such that its distance from the point of application of force is 5 units.
F is in the plane of paper →T will be perpendicular to the line joining OP. By geometry you can find the angle that Torque makes will axis (37∘ here).
Now this torque along axis will be →T cos 37∘ = 5×10× 45 = 40
Which is same as previous. You can also generalize this by taking any other θ.