The best option to correct the dangling modifier in the sentence is:
A gray whale was swimming through the ocean, slapping its fin against the water.
This revision clarifies that it is the gray whale that is swimming and slapping its fin, correcting the original structure that implied the fin was doing the swimming.