The hilarious moment was prompted by Miranda Hart on stage when William and Kate attended the show in 2017