You mean like swim across Starling Inlet to Shenzhen? Of course there are laws requiring you to complete immigration clearance when entering or leaving the territory. If you don't get cleared when leaving, Immigration will record you as an overstayer. That's not good.
Given that few swim their way out of Hong Kong, the most common exit/entry method that doesn't encounter a physical barrier is by ship. And in that case, you're supposed to anchor at a designated place and await clearance, unless you qualify for Special Arrangements.
http://www.mardep.gov.hk/en/pub_serv...an/pdf/imm.pdf