That example is exactly what happens in Forex with mid size brokers/platforms and they even have it on their front page info that they will trade against you at times. I can put in a position on a total flat line period and watch an instant position go against me, and stay moving further towards my stop until it stops me out almost in seconds. It's a computer there. And not illegal as far as I know. It's currency futures.
I don't believe any MM's with stock have that capacity or even need to. Like Janice said, they make it on the spread, either way.
Also, you said influence price based on the way volume will go. There is no predicting volume so an algorithm can't work without having the data to 'work' on.