An elephant cannot voluntarily stampede. The only way to do what you propose would be to attack it with your own troops. And even if you did manage to somehow pull off such a complex and 'gamey' maneuver, the net result would be exactly the same as if the elephant had simply charged straight ahead in the first place, so there wouldn't be any point to it.
The semi-random direction of an elephant stampede righty depends on the beast's original facing. If it was instead based on the direction from which the enemy attacked, then the opposing unit(s) could attempt to force the elephant to stampede 'sideways' down its own battle line, which IMHO would also be rather 'gamey.'
"Experience is the teacher of all things."
~ Gaius Julius Caesar