You would probably encounter the last pokemon your friend sent out as normal because link cable battles do not change your name; the old man trick does and the byte for the name interferes with the same byte for the pokemon last seen. At the end of the link battle the trainer sprite would appear possibly not affecting the last pokemon seen at all but if it did it probably would not have any effect because if you use a code to make trainers actual wild pokemon they will change into the properties of the last pokemon seen.
If your opponent had no pokemon though or 'M as his last pokemon you would encounter 'M or the pokemon you saw before that because 'M is used as value 000 or it would probably not affect what pokemon you saw in the first place.
If your opponent had a team of example: Charizard, Mewtwo, Golem, Exeggcutor, Chansey, Mew you would encounter the last pokemon (mew) and so that is a good way to get unattainable pokemon although since the script for a link battle is different it may not work, you could give it a try though.