Yes, deployable airbags might work.
Why OP's idea won't work?
To keep the ship afloat you'd need at least 30% of its size to be the air compartment, which would greatly limit the space inside, and this way increase the transport cost.
When a cargo ship takes in water, its center of balance changes, so the air compartment won't change anything. You'd need special flood chambers, where you'd pump the water to keep the balance. (Japanese WWII battleship Yamato had this.)
There's a reason why submarines have ballast tanks on the outside