Let us consider the given diagram, where weight of the door acts along negative y-axis.
A force can produce torque only along a direction normal to itself as τ = r × f. So, when the door is in the xy-plane, the torque produced by gravity can only be ±z direction, never about an axis passing thoroughly y direction.
Hence, the weight will not produce any torque about y-axis.