The United States will invest tens of billions of dollars to boost maritime cybersecurity around its strategic seaports, including by replacing China-made container cranes that officials believe could leave American infrastructure vulnerable to sabotage.