For the PlayStation 2 version of Star Wars Battlefront 2, here's how to activate invincibility. While you're in a battle, hit the pause button and hold down L2 and R2, then input the following sequence:
Up, Up, Up, Left, Down, Down, Down, Left, Up, Up, Up, Left, Right
You'll hear a sound when you pause if you've entered it correctly. Keep in mind the effect won't wear off until you shut down the game system, so use it wisely.