Absolutely set this up ahead of time. If you don't, you will at a minimum be inconveniencing all the other passengers when the ship waits (however long it's going to wait) to see if you return, and there could be additional hassles if the ship a) leaves anything with the port agent where you departed, and b) deactivates your card, closes your accounts, etc.
My Dad did this (quite a few years ago now) on a cruise to Norway - it was an unusual itinerary where the ship stopped at city A, went on to city B, and returned to city A. We have relatives in city A, so Dad thought he'd stay with them in-between the ship stops. My only advice was to make sure the ship crew knew and approved of his plan - he did, and had no problems. But that was some time ago, things may have changed.
The ship crew also needs to know because of (as noted above) customs/immigration regulations, and there could be restrictions like the US's PVSA to be considered. (The PVSA itself applies only if you get on in one US port and off in another, but other jurisdictions might have their own rules.) Also keep in mind the possibility that the ship may need to skip your planned reboarding port for weather or other reasons.