For example - 'Anti-Machiavel' by Frederick the Great. Was he an exception or was the publication of academic works by monarchs more frequent?
It was generally not common. Certainly there were some monarchs who did have some scholarly abilities. Queen Elizabeth I translated Boethius's Consolation of Philosophy.
But the amount of training in languages and literature necessary to be a truly accomplished scholar was tough for a monarch to achieve. They tended to be more patrons of scholarship (like Charlemagne or Alfred the Great or Catherine the Great) than scholars themselves.