Gene Hackman does not star in a film primarily set on a train. However, he has a significant role in The Royal Tenenbaums (2001) as Royal Tenenbaum. The film features a memorable sequence aboard a train where the estranged family reunites. If you are thinking of a classic train thriller, you might be conflating him with:
The Royal Tenenbaums is the closest match for a Hackman film with a key train scene.