For centuries now, the monarch has kept themselves from commenting publicly on practically any political issue. The last time an Act of Parliament did not receive Royal Assent was in 1708 and that particular instance was on the advice of Queen Anne's Government. While withholding Assent is one of the more drastic ways the monarch might influence politics, this timeline in and of itself shows hows rare the entire idea is nowadays.
Since Queen Anne, quite a lot has happened. A new Royal House was installed after her death as she left no heir; this imported Royal House became distinctly British with Queen Victoria (who was not eligible to become Queen of Hanover), the British Empire rose and fell, etc. What would happen if the monarch were to make a public political comment is a question of guesswork nowadays. As o.m. writes, they would get at most one try.
In all likelihood, we are not going to see an example that we can study. For one, the current monarch has and future monarchs will have staff to ensure that what they utter in public does not violate the unwritten principles. For two, the reigning monarch has far more subtle ways of influencing politics at their disposal. Most notably, there is the weekly meeting with the Prime Minister whose contents are understood to be entirely confidential (and to the best of my knowledge have been throughout Elizabeth's reign). I would expect the monarch to use such informal channels if needed and desired to state their stance on political issues to avoid their name being attached to any specific position.
The mileage varies for other members of the Royal Family who are not the reigning monarch.