Total invincibility does not exist in San Andreas, but infinite health gets you most of the way. Enter this at the pause screen:
Down, X, Right, Left, Right, R1, Right, Down, Up, Triangle
Even with it active, three things still kill you: explosions, drowning and falls. So you can walk through gunfire without a scratch and still die to a badly judged jump off a bridge. The code has to be re-entered after loading a save or dying.