I know it's extremely unlikely a rogue planet passing by there, and I know the size of rocky planets can vary a lot (IIRC there is a rocky planet 5 times the size of Earth) but in any hypothetical case, could a rogue planet be trapped in any part of the orbit between Earth and Mars? If so, which are the possible effects it could have over Earth and Mars? In which cases would they be expelled from the solar system?
It is exceptionally unlikely.
Imagine that there was a planet already there. What could cause it to suddenly escape from the solar system? It would have to be a massive event, such as a second passing rogue planet catapulting it out of orbit.
Running time backwards, for a rogue planet to be captured and neatly end up orbiting between Mars and Earth would require an unbelievably unlikely sequence of events, such as
two rogue planets happen to pass between Earth and Mars at the same time and the interaction between the two results in a transfer of energy and momentum, which (by lucky chance) leaves one of the planets in a nearly circular orbit, (while the other escapes)".
Given how big space is, and in consequence, how rarely a rogue planet enters the inner solar system, this would make the above sequence of events practically impossible.
In this unbelievable scenario, the effects on Earth and Mars would depend on how closely the new planet passes. If we are close enough for significant effects on the planet, we are in a great deal of danger.