Expose for the sky
You need to set your exposure for a silhouette before the train comes into view. Using manual exposure, take a picture of the scene as you want to frame it so that none of the sky is burnt out. You can check this by looking at the histogram and ensuring the graph is not pushed up towards the right. If it is, try again with a narrower aperture.