When a Dead Swordfish is left to spoil, it will turn into a Spoiled Fish.
To fight Swordfish, boat speed of 7 or above is recommended, adding both Boat and the Sail speed. Sailing close to the Swordfish will cause it to attack, which can be dodged by sailing in the opposite direction after the Swordfish pauses before the attack. Then players will be able to land 1 to 2 hits with a melee weapon depending on boat speed. Swordfish cannot be stunlocked.
The player can also dock near a herd of Water Beefalo and let the Swordfish attack the Beefalo. The Beefalo, fighting in groups, will usually win, resulting in the Swordfish's death. However, the player needs to actually get on land for this strategy to work, as the Swordfish will not attack other mobs while chasing the player.
If playing as Wendy, one can let Abigail attack the Swordfish and even persist until it dies, if given enough time. Note that the Swordfish doesn't change target when fighting, so the player must be wary and ensure to continuously fleeing while Abigail finishes the job. This, on the other hand, can make the process of killing a Swordfish completely safe.
It'd be wise to save the Swordfish for crafting the Cutlass Supreme as the weapon can serve as a sturdier and saner alternative to the Dark Sword.
There is code in the game files that would allow using alive Swordfish in the Crock Pot, counting as 1 unit of Fish and 0.5 units of Meat. However, there is no method implemented that would make capturing Swordfish alive possible.