[This is an unresearched answer, based on my own experiences/thoughts. Within the guidelines of this site it may not therefore be appropriate, but I hope that it at least helps the OP]
"Mayor" is more of a title than a noun, and as such it often appears without an article. "King", "Queen", "President", and I'm sure many other similar terms, are treated the same way.
To make some example sentences, I'm going to talk about my school history teacher.
It sounds unusual (to my ear) for me to say to someone random:
My history teacher was mayor in 1998
because there is no context around "mayor" - there are many mayors across the world, which one was he?
It also sounds unusual to me to say:
My history teacher was a mayor in 1998
It sounds completely normal to say and of:
My history teacher was mayor of my town in 1998
My history teacher was Mayor of Canterbury in 1998
My history teacher was the Mayor of Canterbury
However, once the fact that he was mayor of my town / Canterbury has been established, that could be done away with in the rest of the conversation:
Me: My history teacher was Mayor of Canterbury
Becky: While he was your history teacher?
Me: No. He taught me in 1996, was mayor in 1998 (if my memory serves me correctly) and then taught me again in 1999 and 2000.
The excerpt you've posted from Macmillan dictionary sounds like it is part of a conversation like this, i.e. where he was mayor of was already established prior to the excerpt.