The easiest way is to use ModelingToolkit.
eqs = [
M ~ 0.1sin(ω*t)
D(θ) ~ ω
D(ω) ~ -3g/(2l)*sin(θ) + 3/(m*l^2)*M
]
structural_simplify with that set of equations will eliminate the extra equation, but sol[M] will grab it from the observed, or plot(sol,vars=M) would plot it.
See the first MTK tutorial:
https://mtk.sciml.ai/dev/tutorials/ode_modeling/
The other way is a post analysis as @gnicolosi shows