We need you to explain if you actually have a passport and are worried about leaving it on the ship, or if you simply do not own one.
In any case, if you have left your passport on the ship and the ship is about to leave without you, most cruise lines send security to your cabin to open the safe and look for your passsport in the most logical place.
If they find it, they pas it to the port agent, who is then legally responsible for you and your passport until he gets you back to the ship or home.
Note that almost every country on earth issues blanket visitor visas for all ship's passengers and crew. When the ship departs, these visas expire.
If you are still in the country when the ship departs, you are there illegally - unless you have made prior arrangements with that country's immigration department, or until the port agent arranges a temporary visitors visa for you.
It can be difficult for him to arrange a visa for you if you do not have a passport.
So suppose you are ashore in Cozumel when the ship leaves and you do not own a passport. First, the ship's agent will assist in getting you a temporary tourist visa. That keeps you out of jail. Then, the nearest American Consulate is 235 miles away in Merida. That's an expensive taxi ride (more than the cost of a passport).
Some American Consulates in some countries can issue temporary, emergency, and replacement passports. In other countries they cannot.
I don't know the official procedure and rules in Mexico. If Merida can't do it, it is a very much longer taxi ride from Cozumel to the US Embassy in Mexico City.
You cannot fly into the USA without a passport. There have probably been exceptions made, but with all the Americans from my ship who get stranded in Mexico without a passport, I have never known of an exception made for any of them.
You can always consider a 3 or 4 day bus ride from Cozumel to the US Border. That must be a memorable experience.