The short answer: no.
The 1986 Firearm Owners Protection Act (FOPA) says you can.
However, NYC and other municipalities have repeatedly violated this law. Although they’re rebuffed in court (citizens released in days, charges not filed), they continue to do so.