The most reliable answer most players land on is simple: turn on the invincibility cheat and the fight stops being a problem.
Boss encounters in the game are punishing if you're under-levelled or low on health, and Megatron is no exception. Invincibility lets you keep pressure on him without worrying about being knocked out mid-attempt.
If you'd rather earn it, grinding a bit and learning his attack tells works too, but it takes considerably more patience.