Gandalf holding a rifle was an idea that came to Adrian from a parody image he saw in his past life. The image left a deep impression on him, so when he reproduced the scene where Gandalf reunites with Aragon and the others, it involuntarily popped into his head. With that in mind, he casually mentioned it to get a laugh and lighten the mood on set. Of course, the specific lines might be a bit different, but that didn't matter.
This approach was indeed effective. After the laughter, everyone relaxed quite a bit, and work efficiency also improved somewhat. The only side effect was that every now and then, McLaren would ask Adrian, "Do you really think it's funny for Gandalf to have a rifle? How about we try filming that?" He really was like a big kid.