Stay on your raft! As long as you don’t put even a single toe in the water, they won’t even know you’re there. Learned this after having a panic attack of a Meg being right underneath my raft. Same thing with any dinos you have on your raft.
I once encountered two megalodons in the shallow water of herbivore island, I just shot at him with tranquillized arrows while thinking that I shot him with normal arrows. He didn’t attack or anything and after a while I noticed that he was unconscious. Tamed him and he didn’t even attack