The owner has to register the ship in the same country they fly their flag from, if the ship fly a Panama Flag, then they would have to register the ship at Panama.
When you fly those countries flag, you are part of that territories in high seas according to the Law of the Sea
Effectively, if a ship is at port, it belongs to the owner, if the ship is in High Sea (ie international water) the ship belongs to the country whose flag they fly. In high seas, the sovereignty of the ship belongs to the flag that ship fly. So, if a ship flying Panama Flag in high sea, regardless of who own it, the responsibility of that ship belongs to Panama authority according to Admiralty Law.
Even if the owner is Chinese, if the ship is underway at sea, China has no jurisdiction what-so-ever if that ship was registered in Panama and fly a Panama flag.