In a world of frictionless pulleys and spherical cows yes, in the real world, no. In the real world aircraft carriers and their attendant battle groups do not just park within visible range of a coast. Your drone swarm needs to find the carrier's battle group, get within launch range for your $50 drones (without being shot down), maintain some sort of identification of the carrier (or whatever ship), and then make a terminal approach.
A carrier's air group maintains a perimeter hundreds of miles away from the carrier group. Not just fighters flying CAP but AWACS planes keeping track of the airspace. No one is going to hide a million drones launching towards a carrier group. It would be unlikely hide even a hundred drones. A drone carrier large enough to launch a non-trivial number of suicide drones is also unlikely to go undetected.
Even if everything went right and someone managed to damage an aircraft carrier with a drone swarm, the carrier group alone has enough land attack weaponry to seriously hurt the source in retaliation. A nuclear response to an attack of a US carrier would not be outside the realm of possibility either.
Attacking a US carrier group is a really dumb idea even if you've got a really clever weapon.
But you might be able to, if they're small enough. Or underwater.
If you can provoke nuclear retaliation, you win twice, at least to the extent that anyone can "win" a battle nowadays: first, you sink Enemy A's carrier (or, more realistically, permanently incapacitate it), and second, you draw Enemy A's nukes onto Enemy B's territory where you launched the drones from.
Swimming + flying cheap drones doable: https://www.youtube.com/watch?v=FC9EJhs0pc0&ab_channel=Rutge...
At (wild overestimate) $1k per drone an attacker can wield 13 million drones for the equivalent cost of an aircraft carrier, not including ongoing expenses.
Clearing the flight deck with antipersonnel warheads would probably work better, but I wouldn't count on that to keep a carrier out of action for very long. If you really want to sink a ship, either use proper anti-ship warheads or don't bother trying.
But there's no particular reason to expect that this future will be a Mohist one in which peace is ensured because magically cheap defensive drone swarms make every fortress impregnable and thus combatants' home territories always remain unscathed; at least as likely is a Second Variety future in which drone swarms are more effective for attack than for defense, perhaps even after all the human combatants are dead.
Though actually I'm coming around to the idea that a bunch of AI-targeted flak guns are sufficient, and that carriers are probably fine either way due to how close a series of missiles containing the swarm would have to get anyway.
There could be an interim period of many years where very important stuff is very vulnerable.
If each drone costs US$50 then you can launch 180 million drones for the cost of an aircraft carrier. I don't think increasing the number of lasers from my 5 to 10-20 is going to help much.
I don't know what is needed for a munition to damage an aircraft carrier, but I feel like once it's on the deck it's already past the strong defenses and into the soft targets. It could be as simple as a wheeled robot that runs around stabbing random people, or a poison gas canister that fills the interior of the ship with mustard gas, or hundreds of hand-grenade-sized mini-claymores that deploy to random parts of the ship and conceal themselves quietly until a sailor happens to walk by.