Still, dozens of people are present during the shooting of any scene in a movie, so how the hell did George Lucas convince them to keep this a secret until the movie came out?
How They Kept It Quiet:
Lucas didn't need to convince anyone, because the actor playing Darth Vader in that scene didn't say "I am your father" on the set -- he said "Obi-Wan killed your father."
Seriously, look at his lips.
As you may know, the guy in Vader's suit and the guy who did the voice are two different people (James Earl Jones would dub over David Prowse's lines later), so it was extremely easy for Lucas to just write the fake line into the script and shoot the scene like that. In fact, Lucas was so distrustful of his own crew that he told the truth to absolutely no one. And by no one, of course, we mean a few select people who had to know in order to shoot the scene in question, but seriously, like no one else.
For a long time, the only person Lucas had told was the movie's director, Irvin Kershner, but they only told Mark Hamill, the actor playing Luke Sykwalker, literally moments before he had to shoot his reaction. Even then, Kershner made sure to point out to Hamill that if the ending got leaked, they would know it was him.
"You know when your character loses a hand in the movie? That's just a preview, kid."