If you mean 'won zero counties outside of NYC', then many races have come close but I can't think of any that have hit that benchmark.
If you mean 'their entire margin of victory came from NYC, the rest of the state voted for the Republican candidate', then sure, this happens all the time. I think this was true for most or all of the statewide elections in 2022. I did the math and it was just narrowly not true of 2016-POTUS (Clinton won NYC by 1,670,026 votes and the rest of the state by 66,559 votes).
I think it was true of all the 2022 races: did the math and Schumer won NYC by 850,700 votes, which means he lost the rest of the state to Pinion by 31,290 votes. He ran ahead of all the other Democrats basically everywhere, so all of them also won solely on account of NYC.
If you moved Staten Island to the “rest of state” column does it change anything?
Staten Island is <6% of the population of NYC so I doubt it will.