The president, whose Manhattan penthouse would be subject to the levy, assailed Mamdani’s plan without mentioning the mayor by name.