Sperm whales can hang vertically in the water while sleeping by releasing gas bubbles that regulate their buoyancy, scientists found.