There is no published formula in advance. The best way to get close is to look at the difference between the current price of what you booked and what you want to upgrade to, and calculate about 50% of that for the cost at the port.
Example: If you are in a cat 11 with a current price of $2000, and the cost of a cat 6 is $4000 (difference of $2000), the price at the port would be about $1000. This is only a rough estimate!
All that said, as the economy improves, there are fewer upgrades available at the port on "normal" cruises. Always book a cabin where you will be happy and don't plan on an upgrade.
FYI, your cruise will disappear from the internet about 3 days before embarkation. Look before that to get an idea of prices and availability.