I was looking into some of the motion equations for a physical pendulum that oscillates in small angles (using the approximation $\sin(\theta) \approx \theta$). Specifically, I was interested in ways to describe the angle $\theta$ between the pendulum and the vertical ("negative $y$") direction, as illustrated below:
Let's say that the pendulum's moment of inertia with respect to its axis of rotation (the blue dot in my illustration) is $I$; that its total mass is $M$; and that the distance between its center of of mass and its axis of rotation is $d$ (the axis is above the center of mass).
I showed (won't burden this question with those calculations) that in this situation, I can consider the force of gravity as though it is acting solely on the center of mass, and so the net external torque $\vec{\tau}$ is given by: $$ \vec{\tau} = \left( d \cdot \hat{r} \right) \times \left( - Mg \cdot \hat{y} \right) = -Mgd\sin(\theta)\hat{z} \approx -Mgd\theta\hat{z} $$ using the right hand rule.
The next step was to use Newton's second law and obtain that: $$ \vec{\tau} = \frac{d\vec{J}}{dt} = I\cdot\ddot{\theta}\hat{z} $$
Which then gives me: $$ \ddot{\theta} + \frac{Mgd}{I}\theta = 0 $$
which is a differential equation I can solve.
However, if I instead observe the pendulum at a stage in its rotation in which it is in the other side, but using the same axes:
then using the right-hand rule I (erroneously, I presume) obtain that this time, the net external torque is given by: $$ \vec{\tau} = Mgd\theta\hat{z} $$ that is to say: the same magnitude as before but in the opposite direction. This results in this being my differential equation in this case: $$ \ddot{\theta} - \frac{Mgd}{I}\theta = 0 $$ to which the solution is rather different.
Obviously, this seems off: I'm describing the same motion here and should therefore obtain identical results. Thinking about it logically I was able to tell that $\theta$ and $\ddot{\theta}$ should be of opposing signs (assuming angles on the right side are "positive" and that positive $\hat{z}$ is the direction associated with a counter-clockwise rotation) and so the first of the two equations seems to be the one I was after; but I'm struggling with proving this to myself through simple algebra, for some reason.
I suspect that the cause may be that I implicitly consider $\ddot{\theta}$ to be a "signed" function with its sign signifying the current direction of rotation, while $\sin(\theta)$ was "approximated" out of an "unsigned" $\sin(\theta)$ (since $\theta$ the way I described it is always in $[0,\frac{\pi}{2}]$), and so the solution should be to turn it into such a "signed" function. Once again, I can logically think (split it into the positive/negative cases) and determine that if it is signed as described ($-\frac{\pi}{2}$ to $\frac{\pi}{2}$, left to right) then $\vec{\tau} = -Mgd\theta\hat{z}$; but I feel like I've been overcomplicating this and would appreciate hearing an explanation from someone with a deeper understanding.
To summarize this as a question:
How, as algebrically as possible (which isn't to say I wouldn't greatly appreciate physical clarifications/solutions as well!), could I determine that $\vec{\tau} = -Mgd\theta\hat{z}$ (assuming that I'm even right and that it is), regardless of the side in which the pendulum currently is?