Great question. I'm surprised that upon searching, I haven't come across a train-push vs pull question in Physics SE. I'll try to give a detailed answer.
TLDR; Conceptually, the pulling engine is better but both push and pull trains are doable and exist in real life. If you're talking about an idealised thought experiment, I don't think there's a difference.
Now, let's talk details. Your force reasonings are accurate in that, you do no more work pulling a weight up a hill than you do pushing it. The normal/reaction force that is relevant to the friction experienced is perpendicular to the push/pull force and as such, cannot contribute to friction's magnitude. However, it doesn't really matter since train wheels almost never slip. Of course, there is the occasional slip where ice, grease, organic matter, etc. are concerned but steel on steel with heavy weight makes for some impressive tractive force. See this question for more details.
In real life, many train companies use both push and pull methods. In a push-pull train, you have dual locomotives in the front and back, sometimes working together, sometimes taking turns. Companies also do pull trains one way and then push them back, saving cost and having to turn the train around. If we're talking pull-only vs push-only trains, it's a different story.
Theoretically, no, the engine pushing at the rear will not have any mechanical advantage over the engine pulling from the front. In fact, it is the other way around. For many reasons, I think the engine pulling has the advantage, however small.
- Easier to see
For one, it is easier and safer to get where you're going when you place your sensors in such a way that the information relevant to your motion reaches you soonest. Almost always, this is the part furthest along the direction of your motion (which is why most animals have their eyes in front). In other words, you get to see what's in front of you before you hit it.
- Easier to make
Secondly, a train that has a pulling engine is much easier to design and build. Most train cars are connected by a "tether" of sorts, which is much closer to a string than it is to a stick. It is a lot easier to design and build connections that are strings that pull cars than sticks that push cars. What I mean by stick is something which is rigid and resists deformation. What I mean by string, however, is something which pulls and is pliable. An interesting aside, I've heard my professor once say that that's sort of the definition of a string in physics; something which can only pull and not push.
Anyway, in real life the train cars don't do well when they are pushed with a string (even a semi-rigid connection). You get collapses and distortions in the overall chain of the train because the connections can't withstand the force intended to push the train. The tracks help mitigate this to some degree but it creates unwanted stress.
- Easier to steer/safer to drive
It only makes sense to push the train if the connections are rigid but then steering the train becomes mechanically harder because the train becomes less flexible as a whole. The chances of derailing are also higher in a push-train than it is in a pull-train although I am aware some experts say that the difference is small enough to be ignored and isn't significant (especially in reference to Glendale 2005 and Oxnard 2015). I think this is because the direction of force is changing sooner with respect to the direction of track change in a pull-train than it is in a push-train. In other words, the pull force changes with the curve and the other cars follow accordingly but the push force remains straight as the cars in front experience the curve in tracks.
- More efficient design
You also get inefficiencies when you push a non-rigid train because all the small things in a train distort whenever and however they can. Forces and these things in general tend to always take the path of least resistance. A path that is non-rigid is by definition less resistant than a rigid one and so whenever a non-rigid path exists and is pushed, it will bend and buckle in a way that it was not designed to do. This creates more friction, wear, tear, heat, noise and in general, more things to account for. Below is just one of the ways I could think of that a push-train going uphill could go awry.
Additionally, a pull-engine has an inherent superiority to a push-engine. Try this; slowly push a cup with your finger across the table. Eventually, you will "lose" the cup. It might slide to the side or be pushed aside by your finger or twist to avoid your finger. Now try pulling the same cup with your finger through its handle. You'll never lose the cup. Not sure how significant this is when there are tracks but I imagine there's certainly a difference.
Idealistically in a thought experiment, I think there is no difference. You'd need some kind of exotic material though, along with perfect rigidity, perfect trains with perfect connections, flawless tracks, etc.
In response to the updated question, with a rigid coupling, both the pull and push engines have things resisting the torque "lift" of the train (weight of front load in push-engine and the back portion pushing into the ground in pull-engine). Note that whether the locomotive is front-wheel, rear-wheel or all-wheel drive is relevant. That being said, I still maintain that the pull-engine is superior because the point here is essentially that the train is doing a power wheelie. The best way to mitigate wheelies isn't by moving more weight to the front of the vehicle, it's by adding a wheelie bar.