According to the writers of Solo: A Star Wars Story, the surprising cameo at the end of the movie was not in the actual script. (Warning: spoilers follow!)
The movie has a twist in the last act when Qi’ra (Emilia Clarke) contacts none other than Darth Maul, with Ray Park and voice actor Samuel Witwer reprising their role as the character. This would come as a surprise to many moviegoers, as Maul seemingly died back in The Phantom Menace.
More dedicated Star Wars fans, however, would not have been as surprised; a post-TPM Maul has appeared in the canonical cartoon series Star Wars: The Clone Wars and Star Wars: Rebels, as well as in at least one novel. Still, the fact that he was the leader of the Crimson Dawn crime syndicate was a twist, and one which was carefully hidden from even the cast members, according to Jonathan Kasdan.
“It was never specifically named in the script. It just said, ‘A character too secret to ever name.’ Everyone did a great job of keeping it secret, and Ray was such a delight.”
Apparently, everybody did find out and showed up for when Park recorded his bit. They were told to keep it secret, however.
For the record, this is not the first time that Star Wars has pulled such tricks. The famous “No, I am your father” line wasn’t in the script, either; on paper, the movie’s big twist was that Obi-Wan, not Darth Vader, killed Luke’s father. Reportedly only Vader’s voice actor, James Earl Jones, was told the real line.
Fortunately for Lucasfilm this particular tidbit did not get leaked beforehand, and whether you like this twist or not, it was certainly a big surprise.