Guns tend to be lacking in modern fantasy tales, but we can not blame the fairy tale sources for that. I have already brushed on war1, and some tales with that mention cannons and sometimes smaller pieces, but that's not even the most common location.
In The Donkey Cabbage, one is used to start all the trouble:
He was going on then, but the old woman stopped him and said, ‘Listen, dear hunter, to what I say. Because of your kind heart I will make you a present. Go on your way, and in a short time you will come to a tree on which sit nine birds who have a cloak in their claws and are quarreling over it. Then take aim with your gun and shoot in the middle of them; they will let the cloak fall, but one of the birds will be hit and will drop down dead. Take the cloak with you; it is a wishing-cloak, and when you throw it on your shoulders you have only to wish yourself at a certain place, and in the twinkling of an eye you are there. Take the heart out of the dead bird and swallow it whole, and early every morning when you get up you will find a gold piece under your pillow.’
Though there are many different ways for the hero of such a tale to gain the magic objects. There's always the classic means of catching and eating a fish, for instance. Or merely being given them as a gift when you have, for instance, helped an old woman. She doesn't have to give you it as advice.
Likewise in Bearskin, when the Devil wished to test the soldier's courage.
The soldier turned round, and saw a large bear, which came growling towards him. "Oho!" cried the soldier, "I will tickle thy nose for thee, so that thou shalt soon lose thy fancy for growling," and he aimed at the bear and shot it through the muzzle; it fell down and never stirred again.
But in many variants, the Devil doesn't test the hero's courage, and doesn't give him a bearskin, counting on the requirement to never bathe or cut his hair or nails to produce the hideousness of the tale.
In Niels and the Giants, Niels shoots among the giants to cause mischief, where others, such as the brave little tailor, threw stones. Whenever they settle down from their quarrels stemming from one accusing the other of causing what Niels affected, he shoots again.
Though once the giants catch Niels, it is an enchanted sword that lets him save the day, and the gun does not feature again while the princess bends her wits to try to discover who delivered her and her castle and left without a sign.
In Go To I Know Not Where, Bring Back I Know Not What, the bird-maiden is won as a bride not by stealing her feather cloak, but by shooting and wounding the bird. She begs him to not kill her but bring her home, and once he does so, she turns into a beautiful woman at midnight and marries him.
In The Golden Bird, it is the second test of the sons. After they have set out in search of the golden bird, a fox comes to warn them.
The eldest son set out; he trusted to his cleverness, and thought that he would easily find the Golden Bird. When he had gone some distance he saw a Fox sitting at the edge of a wood, so he cocked his gun and took aim at him. The Fox cried, "Do not shoot me! and in return I will give you some good counsel. You are on the way to the Golden Bird; and this evening you will come to a village in which stand two inns opposite to one another. One of them is lighted up brightly, and all goes on merrily within, but do not go into it; go rather into the other, even though it seems a bad one." "How can such a silly beast give wise advice?" thought the King's son, and he pulled the trigger. But he missed the Fox, who stretched out his tail and ran quickly into the wood.
Then, the older sons do not have to shoot at the fox. They can just ignore what it said.
A little more significant gun appears in How Six Men Got on in the World, where one man is a huntsman whose idea of a good shot is "Two miles from here a fly is sitting on the branch of an oak-tree, and I want to shoot its left eye out." He is one of the five men with special skills, such as causing frost or carrying trees, and when their speedster falls asleep, he can shoot out the skull he uses as a pillow and so wake him. Still, all sorts of improbable skills can be combined in that tale type.
From which you can quickly see that in the matter of motifs, guns are more like roses than like dancing2 -- they are found here, there, and everywhere, but they are not integral parts of tales.
Indeed, the gun seem to be festooned over the beginnings of tales. The tale where the hero kills the dragon and rescues the princess is rather more rare than you might think, and in those tales, he uses a sword. Likewise, they fight in wars and tourneys with swords, when those fights are significant to the plot.
The only one where the hero fires a gun more than once is Niels's, and he waits for the trouble among the giants to settle down before he fires it again. All of these could be among the earliest guns -- at least, the earliest that allowed sharp-shooting.
Then, given the way the fights are short in story even when we are explicitly told they are long, it would be fairly simple to have a soldier stand with cool bravery and wait as the dragon approaches and coolly take aim and kill the dragon with a single bullet.
I have not read such a tale, but I would not be surprised to read it.
Such are motifs in fairy tales.
See
Hunting Down Motifs
Let's suppose you have decided to have a character tell a tale in your story. And you decide to underscore one of your motifs. This can be adroitly handled because your character is, in fact, keenly aware of the motif.
I have only advanced to crossbows, telescopes, and magical bombs in my fantasy world.
Years ago, I read part of a series where there were gunpowder mages. The Powder Mage trilogy.
But I doubt they could be called Fairy Tales.
Maybe it's just me, but a story that ended with 'And the hero shot the dragon dead with his Barrett m82. Then he went back to town and had a good meal and a pleasant night's sleep. The End' would be just a little disappointing.
Even if real life it'd be the smartest way to handle such a situation, provided such a weapon was available. And I've known of a lot of tabletop gamers who love set-ups like that. Of course they complain when the monsters start fighting smart, too.