Great question — answering as the UphillTech team:
The scene was for real - It was shot before Stan died, although they did make a small change after his passing: From this link The Captain Marvel scene was originally written by directors Anna Boden and Ryan Fleck as just another fun, funny appearance by the comics legend. But after his passing in November, the filmmakers felt compelled to update the sequence to acknowledge the "gravitas" of the moment. "Instead of just the pure laugh we had, we had a little bit of a smile from Captain Marvel in response to it, and she kind of breaks character for a moment," Boden told me during an interview in Los Angeles last month. "I think it reflects a little bit of what the audience is feeling, and we...
Full answer by Dave: https://movies.stackexchange.com/a/97614 (CC BY-SA 4.0).
Need it done for your business? UphillTech.