Usually, train journeys are fine if you carry your own home-cooked light food and bottled water. But if you have any cramping, spotting, or back pain, please cancel the plan and check with your gynac immediately.
I think it is safe if you are in the second trimester and everything is normal, but I would feel a bit scared of the jerks. Maybe consult your doctor gently before booking the tickets.
Haan na, train travel is usually much more comfortable than road trips during pregnancy. Just try to book an AC sleeper seat so you can lie down comfortably. But still, doctor se ek baar permission le lo.
My family was very hesitant about train travel, but my gynac said it is actually safer than bumpy car rides as long as it's a smooth journey. Just make sure you get a lower berth and avoid lifting heavy bags.
When I had to travel, my doctor clearly advised me to avoid long travel during the first and third trimesters. They gave me a proper travel clearance letter and told me to walk in the corridor every hour to keep blood circulation going.