How does this work? Seems more like a law but cities dont have legislatures. Or … ?
It works because they are allowed to by the state, by a process specified by the state. The rules and ordinances of a county or municipality are subordinate to the laws of the state that granted them existence in the first place. There's a lot variety in "by a process specified by the state", which results in different structures: commissions, charters, mayoralties with councils, and more.
Cities have city councils that pass laws.
This likely doesn't even require a new law. There is probably an existing law against deceptive advertising in renting. This is just the mayor announcing that he will interpret the existing law to cover AI generated staging images.
well, reading the article Mamdani is cracking down on "deceptive landlord practices" thus it means his administration will apply deceptive landlord practice laws to use of AI images in advertising apartments. At some point if somebody wants to fight the issue they can take it to court.
As a general rule you probably don't need new laws to penalize behavior you think should be penalized, there are more than enough laws where a good faith interpretation would fit.
Cities in the US can pass laws. They're called local ordinances: https://en.wikipedia.org/wiki/Local_ordinance#United_States