Depends on what megazord. I''m leaning towards the megazord plainly because it has way more power than Optimus. However, Optimus is smart, very smart. And has fought stronger opponents before. So really it could go either way.
Optimus should be about the height of Megazord's ankle. If Megazord doesn't win using his flashy sword powers he could just step on Optimus. Optimus is tough but Megazord is just to big and powerful in this case.