The critique by Mr. Shapiro, the governor of Pennsylvania and a prominent Jewish elected official, shows how deeply Mr. Mamdani’s primary win in New York City has shaken Democratic leaders.