Groucho used to do that in the Marx Brothers movies.
I was listening to an interview with Alex Lifeson, guitarist with RUSH. He said for his solos during a song he had several general ideas of how it would go based on the lyrics and the other music of the song. He wouldn’t practice anything beforehand.
He would go into the studio and play 4, maybe 5 different solos freehand (improv?). The producer would pick and chose from each attempt and maybe reorder the sequences, etc. Alex would review it and make some tweeks, but generally trusted the producer.
Then of course play the “new” solo for the album and concerts.
Interviewer: Wasn’t that hard to play it all out of order and with different versions mixed together?
Alex: Well, I figured I had played the notes once - I could do it again.
(The solos were recreated by listening and playing - not reading sheet music. Alex could read music to a certain extent if he had to. Neither the drummer or bassist could read music!)