Pixar wiki says
Gazerbeam was one of several retired supers who were recruited to battle an Omnidroid on Nomanisan Island as part of the droid's battle education. He destroyed the Omnidroid v.X4, then was bested by its successor, the Omnidroid 5. He was killed by the 5, but not before learning about Operation Kronos. Though the film does not show how, he learned the password for Syndrome's database, "KRONOS," and used his powers to carve it on the wall of a cavern before he lost his life.
While this was not explicitly shown in the movie, it's not too difficult to deduce how Gazerbeam may have chanced upon the password. You see, Syndrome like the stereotypical villains he once wanted to catch has fallen into a similar pattern. He has started monologuing once he believes the superhero is well within his clutch and nowhere to run. Cue scene on Nomanisan Island after Mr. Incredible makes his escape and Syndrome zaps him with the freeze beam. He even acknowledges that Mr. Incredible had him monolouging when Mr. Incredible slyly moves away to chuck a fallen piece of tree trunk or rock at him.
I believe something similar may have happened when he bested Gazerbeam. The megalomaniac that he is, he probably couldn't resist unveiling his grand plan to Gazerbeam in his final moments. On his last breath, Gazerbeam probably jumped into the waterfall that Mr. Incredible jumps into later and reaches the cave where eventually Mr. Incredible finally finds him (or rather his skeleton).
Now, Syndrome may not have gone to the extent of saying, "Hey Gazerbeam! The password to my system is KRONOS". But he almost certainly would have dropped the name Operation KRONOS and Gazerbeam in his dying moments etched on the walls of the cave the only piece of valuable intel he had, hoping that someday it might help someone bring down Syndrome.