This is usually checked based on the expected transit time before you board the previous flights. An airline will always check if you meet the conditions for the destination and all transit points, based on their notion of what your itinerary is.
(As an aside, remember that they do that to protect themselves, as countries will fine them if they let somebody arrive which doesn't meet entry or transit requirements. They don't do that for you, and they don't owe you anything if they miss something or change their mind along the way. Quite the opposite, you are liable for any fines that may be levied against them, as well as the cost of the flight back, at the full last minute rate).
Given the number of connections in your itinerary, expect airlines to check again at each airport, and do not expect them to apply the same rules the same way at each airport.
Since your ongoing travel from PTY to NAS is on a separate ticket, they may actually consider that your final destination is PTY, and refuse boarding altogether as you don't have another flight on the same ticket and you don't meet entry requirements for PTY. They may do so at CMB, at DXB, or at GRU. Given the very short connection time, even if they would normally accept a self-connection, they may refuse in your case considering the flight as a connection as the risk of missing it is too great. Again, they may think it's fine at CMB but change their mind at DXB or GRU.
If they do accept your separate ticket, then if at some point in the itinerary they find out that you won't make it, they may stop accepting it and refuse boarding (this is actually a very strong possibility). For instance, if at GRU the flight is delayed and they know that you won't be able to make it onto the PTY-NAS flight, they will nearly certainly refuse boarding in GRU.
If you still end up in PTY and miss your self-connecting flight, then the first issue is that it's possible the airport or the terminal closes at night. It does not seem to be the case at PTY according to sleepinginairports.net but their info does not seem to be up to date (they mention 2019 as being in the future), and with Covid restrictions things may be quite different.
Even if the airport is open, if you stay there a whole week (probably not a good experience) you'll probably get noticed and at that point trouble begins (a much worse experience, as you'll probably be put in custody until they manage to ship you out of there -- at your expense of course).
You say that in this event you would instead book a trip back. First, remember that last minute ticket prices may be significantly more expensive. Next, especially these days, flights can be cancelled, so it may take quite a bit longer to get a flight back home. Also, I haven't checked Covid-related restrictions for transit along the way, but if any country on the way requires a recent negative test you'll probably be in a difficult situation.
Even if you do find flights back, you may still be noticed by the authorities and get into trouble. They'll be glad you're flying back, but that may not prevent them from putting you in a cell in the meantime if they're so inclined.
As I already told you, I still think this is a bad idea. You should try to get a visa for Panama, that would make things a lot easier.