No way. Given just a differential, just a pair of connections, there's no way for a circuit to tell which is which.
If you had access to phase information about the grid, you might be able to do it, but as the mains frequency isn't terribly constant, you would not be able to rely on predicting this. Your device would have to get information about the present phase angle of the mains from someplace.
However, if you do have a real earth-ground reference from some place, you could build a circuit to look at the voltage of each supply line with respect to ground. One will be a small drop below the full 120 (or whatever the local mains supply) whereas the other will be slightly above ground. (Neutral return current vs your neutral run's resistance). This would just let you know which leg was 'hot', and you could swap your output polarity accordingly.
A Second Thought
If the power supply has only four connections with the world, two from the mains plug, and two to output the DC, there's no way I can think of that you could deterministically set output polarity based on plug orientation.
BUT
if you're willing to make your otherwise simple supply a lot more complex, you could conceivably make it so that if you pulled the plug and flipped it, and plugged it back in straight away, the output would flip.
Here's the idea: You stuff some kind of micro-controller in the box, that monitors the line voltage, and determines when rising-crossing-zero (or some other phase point) happens on one of the legs. You'd have to reference this to the midpoint of the two supply legs via a voltage divider. The micro could then anticipate when the next such phase point would occur. Now you'd also have to put some kind of super-cap in the box and pick a low power micro that could live off the super-cap long enough for the user to flip the plug. When power comes back, either the anticipated phase change happens when you expect, or half-way between. Half-way between means the user flipped the plug, so your micro flips the output polarity.
Of course, that still would be problematic. If the thing had been unplugged for a while, the micro would be dead, and you'd have to make an assumption about what the output polarity should be. Finding a micro that could last maybe 10 seconds on a cap's worth power while actively chugging away could be easier said than done. Last and not least, this would really only be a novelty gadget.
Best Answer
simulate this circuit – Schematic created using CircuitLab
Figure 1. Two possible solutions using off-the-shelf transformers.
Note that L1 will have to supply twice the current. This will result in some voltage drop and heating of the supply line but is probably deemed OK for a temporary fix.
simulate this circuit
Figure 2. (a) The original again and (b) the same circuit rearranged.
If you're willing to believe that Figure 1a or 2a works then have a look at 2b. Here I've just taken the secondary coil and moved it round to the "primary side" of the schematic representation. On the real transformer they're still on the same core and nothing has changed.
The reason it works is that the P winding is energised by L1-N and the S winding is energised by transformer action. It is important that the phasing is maintained - note the dots on XFMR1 which show the relationship between the voltages. If we swap the secondary winding orientation then L2 would be in phase with L1 and you'd have L1-N = 120 V and L2-N = 120 V but L1-L2 = 0 V.