Taking $F_{in}$ as the reference, it is $F_{in}= F_{out} \sin(\theta)$, which makes mechanical advantage proportional to $\frac{1}{\sin(\theta)}$, or $\frac{l}{w}$ for small $θ$.
Taking $F_{out}$ as the reference, as you have chosen, it is $F_{out}= F_{in} \cos(θ)$, which makes mechanical advantage proportional to $\frac{1}{\cos(θ)}$, or $\frac{1}{(1-sin^2(θ))}$ where a simple approximation is not so clear.
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.
Edit
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.
Best Answer
The mechanical advantage is equal to $\dfrac{\text{load “lifted”}}{\text{effort applied}}$
Consider an inclined plane with no frictional forces acting.
The effort needed to push a weight, $mg$, up the slope is $mg \sin \theta$.
So the mechanical advantage of an inclined plane is $\dfrac{mg}{mg \sin \theta} = \dfrac {1}{\sin \theta} = \dfrac{L}{h}$
Later
With wedges there are a number of approximations which have to be made and if one of them is that is the angle of the wedge $\theta$ is small then $\sin \theta \approx \tan \theta$ and this approximation is equivalent to assuming that the hypotenuse is approximately equal to the adjacent side.
For the wedge which is used for splitting wood there is a similar analysis except that the “load” force is at right angles to the surface of the wedge .
Assume there is no friction then the forces which act on the wedge are shown below.
The effort is the force on the wedge $E$ and $G$ the force on the wedge due to the wood which is being split which is equal and opposite to the force exerted by the wedge to split the wood.
$E = 2G \sin \theta \Rightarrow$ mechanical advantage $ = \dfrac G E = \dfrac {1}{2 \;sin \theta}$
Referring to the diagram $\sin \theta = \dfrac {h/2}{L} \Rightarrow $ mechanical advantage $ = \dfrac L h$.
You may wonder about the position of the load force but if you examine a wedge which is used to split wood (right hand diagram) and the head of an axe they both have concave surfaces.
So the position of the load force is a reasonable assumption but it does mean that the mechanical advantage changes a little as the penetration of the wedge increases.
There are other forces in action which have been ignored.
The force on the tip of the wedge due to the wood and also the frictional forces.
For an axe that friction force is reduced by making its surface as smooth as possible.
On the other hand a wedge which is used to split wood is designed not to pop out between being hit by a hammer by having a surface which is ribbed.
All in all the theoretical value of the mechanical advantage of a wedge does give an order of magnitude for its force multiplication but not really much more.