What are the requirements for an aircraft's tail number to match the registration?
What happens if an aircraft changes its number? Is it grounded until the new number can be painted on?
The registration number painted on the aircraft is required to match the aircraft's registration certificate (and airworthiness certificate). If the numbers don't match the aircraft's paperwork isn't in order, and it can't legally be flown.
There is a procedure for changing your N number which is usually used to put a "special" (reserved) number on an aircraft:
N___UAtail number from their reserved block).
One of the copies of form 8050-64 becomes your temporary registration certificate at this time, and you must carry that along with your original registration certificate showing the old registraton number.
As long as you comply with the requirements for the registration number change the aircraft is only "grounded" for as long as it takes to apply the new registration number (if you're repainting this could take a while ; if you apply a large sticker with the new number on it it could be done in less than a day).
I think you're also asking about Airline ship numbers (or fleet number, etc). All airline aircraft in the US (and probably most other countries) have to have a registration, and most airlines also have a ship or fleet number. This is the number that's approved on the airlines OpsSpec (Operations Specification, that basically outlines the entire airlines operations, from Diversion airports to numerous other considerations). If what I understand is correct, an airline just lists the aircraft N number, with it's internal number (whatever they want it to be, sometimes a part of the registration, other times completely different). As long as it's documented, and any changes are documented correctly, it doesn't matter how they correlate.
In the image below, you see the ship numbers on the nose door. The registration would be near the tail, and there are FARs for sizing and placement of that. Also, it's rare that an airline will change the registration or fleet number.