The smoke stack is actually part of a venturi that starts from a nozzle where the cylinder exhausts into the smoke box. It is not just any old pipe.
That said, a less efficient steamer could conceivably have the exhaust from the cylinders to a smoke exhaust in front of the cab to keep the cab from filling with smoke in tunnels. There have been some odd-smoke stack designs.
Since the cylinder exhaust nozzle is fed by regular pipes, I guess the nozzle could be piped just about anywhere (even on top of the steam dome) and the flues could be doubled back for a rear location for a smoke stack. It would look really funky but maybe it is possible.
Doug vV