Several European left-wing officials said they had been in contact with members of Zohran Mamdani’s campaign in New York in the hope of emulating his success in future local elections.