There certainly is some form of contingency plans in the event of such an incident. They remain low key but they are certainly present. In the present world context, the contrary would be most surprising.
Everytime, I have sailed from a USA port, the coast guard cutters accompany the ship into and out of the harbour. The last one ex San Diego had a .50 cal (?) mounted on the small deck on the bow.
As for foreign ports, I did not notice anything special except establishing a security perimeter for those embarking the docked or anchored ship.