"I am going to be a mayor" is perfectly grammatical, but would be unusual. "I am going to be Mayor" or "I am going to be the mayor" would be more common.
By contrast, "I am going to be a teacher" sounds perfectly normal, because "a teacher" is a common class to which people can belong. "Mayor" is a more specific position or title, and in most contexts you wouldn't generalize. (Now if you're a mayor-elect at a conference for elected officials, you might say that "I am going to be a mayor.")
Montreal, Quebec currently (2019) has its first-ever female mayor, Valerie Plante, and she is referred to as "la mairesse" in the press (and in the city's official website: https://mairesse.montreal.ca/ ). As an anglophone living in Montreal, I just took for granted that the term had masculine and feminine versions, like so many other job titles in French. Seeing Sitesurf's comment, though, I'm now wondering if Madame Plante made a political decision to reclaim the femine term. Interesting!