Surprisingly, the bigger the boat the more effective. We tend to have a bias against larger machines, but often they can be the cleanest in proportion.
[1] https://www.ademe.fr/sites/default/files/assets/documents/86...
As for the comparison to trains, it matters a lot whether you're talking about diesel or electric trains. Most train lines in Europe are electrified, and as electricity production switches to solar/wind, it may actually end up being cleaner than ships. (Although work is also being done on making ships cleaner. But new international laws are probably needed to get everybody on board.)
The real issue, though, isn't no much whether the transport happens by boat or train, but that it happens at all. The scale of global shipping is this big because everything is produced on the other side of the world. Big ships make that transport more efficient, but a more egalitarian global economy that didn't create incentives for companies to seek out every low-wage country and tax haven, would make local manufacturing more attractive and reduce global shipping.
"Maritime transport emits around 940 million tonnes of CO2 annually and is responsible for about 2.5% of global greenhouse gas (GHG) emissions (3rd IMO GHG study)."
https://ec.europa.eu/clima/policies/transport/shipping_en
The problem is that we (as a species) are moving far too much, far too far.
https://cs.m.wikipedia.org/wiki/Starship_(raketa)
And it makes sense if you think about it - as you scale up, the ammount of fuel you can carry goes up roghly by cube while structure mass, forming a shell effectively arround the fuel, goes up by square of size of the rocket.
Similar things for air resistance - as you scale up yuour rocket the front part creating the most drag will scale more slowly than the volume of the rocket that goes to fuel, payload and structure.
No wonder Starship is already at 9 meters of width and 18 m has been mentioned as a possible future upgrade. Its already bigger than the massive 66+ meter high medieval watchtower in my home town yet it can fly to sub orbital speeds without its first stage booster (which is even bigger)!
Assuming that pollution primarily caused by fuel usage of course.