score:12
do the passengers have to pass the immigration
Generally yes. Once you are through exit controls, you are out of the country, and you need to clear immigration again to return.
Example: I was in China waiting for our plane to depart at the international gate. The flight was cancelled and they needed to put up passengers for the night. That required full re-entry into China and the Chinese government set up a processing line for those people who needed another short term Visa (since their single or double use Visa was invalidated at departure). Apparently that happens often enough that they have staff for this on hand. Happened a few times to me too.
It's a bit murkier for the US since there are no exit controls and the domestic departure area is no different from the international one. Technically they could decide either way. I'm not aware of any specific regulations for this case, so chances are, it's up to the local shift leader to decide how to handle this.
UPDATE based on an answer from law stack exchange https://law.stackexchange.com/a/76628/15309
Passengers and crew on flights departing the United States for foreign destinations that make an unscheduled stop in the United States due to any emergency, including but not limited to fuel related, weather-related, mechanical-related, illness on board, or other emergency reason, generally are not be processed by CBP, but treated as a domestic arrival.
So the guidelines say that they passengers don't have to pass through immigration but whether the local CBP manager would follow the guidelines is anyone's guess.