In a world where people have Steam technology, and Airships, how would a society come about having such technologies, yet still mainly use medieval weaponry and fight in pitched battles in the absence of firearms? (If it's even possible at all)
There are a few methods for what you want to do. One or a combination can be used.
A) In our world, east Asian is generally accepted as the first location where gun/black powder was first weaponized. This tech spread west via trade, diplomacy and conquest.
- You could simply have the culture that learned to use black powder as a weapon either isolated, wiped out or completely refusing to share their knowledge.
B) A disaster. Nothing like a horrible event to get people behind outlawing what was blamed for it.
- You could have the "Incident of Blank", "The Blank Disaster of Year" or something similar. (Example: an arsenal exploded and killed numerous important people putting the economy in a tailspin or wiped out a major city). This event must be horrible enough or through propaganda, made to seem horrible enough for people to call for a ban on black powder. Earlier incidents and accidents could be used to further bolster prohibition.
C) Unavailability of a component of black powder.
- Charcoal and sulphur would almost be impossible to not exist in a Steam Punk World (or almost any setting for that matter). But pottasium nitrate, aka salt petre, would be easier to at least limit. Guano from bats and birds was the oldest most prevalent natural sources of pottasium nitrate. It is also found in trace amounts in some caves, manure and urine. Though it sounds harsh, just have all most birds and bats extinct or very rare in your world. Maybe an earlier "gun powder craze" led manufacturers to capturing the animals and through their mistreatment or disease died off completely or to near extinction.
The other advantages if using one or more if the above would be additional storyline/plot elements. -Who was behind the "Blank Disaster of '97"? - What culture possesses these near legendary weapons that belch fire, lead and steel? Will they leave their homeland and seek to conquer the world? - Are there any birds/bats left? Where are they? -A company found the pkans to making blackpowder weapons but need a large salt petre (potassium nitrate) source. Where? And howcan this be done without being investigated by the Crown?
Adventures could center around some or more of these questions.
Hope this helped.
Without having a bit more background information on the setting described other than 'steam punk with airships' I'll have to give you a few vague answers, rather than being able to pinpoint a more exact explanation.
I would think that using gunpowder or firearms on an airship would range from insane to borderline suicidal, seeing as a fire would be even harder to put out in the sky compared to a traditional sea faring ship. Even more so if the ship uses any kind of flammable material for buoyancy. Steam powered projectile weapons or pellet guns that use air pressure (and require an attached steam pressure engine) may be too bulky or cumbersome to bring on an airship where you have an exact weight limit beyond which the ship cannot leave the ground.
Having weapons that specifically cannot be used on airships may be enough of a deterrent that they are not deemed to be practical weapons, if airship to airship sky battles are the primary form of warfare in your setting.
Alternately, seeing as steam power is a different tech tree than our own, it's entirely possible that firearms were either never invented, or simply not perfected to the point that they have been in our own real world history. If the only known explosives recipes in your setting are even slightly less powerful, or less predictable, firearms may simply be out of reach until those discoveries are made.
Another possibility, in a world that relies on steam power, high quality metals may be in a high enough demand that it may simply be easier to make cheap iron swords, and wooden bows, rather than expensive finely crafted firearms, and the complex chemicals needed for gunpowder.
By having a strong dislike of gunpowder
This is pretty simple to craft: In your Steampunk world, Airships are the primary military superweapon. Popular fiction and entertainment heavily draw from their lifestyles. Since they are the main component of your military doctrine, weapons and equipment must be designed around their limitations.
Modern airships are filled with Helium. Helium provides the lift/buoyancy of an airship, with the steam engine providing thrust. Helium is used because its not flammable. However, if a society or culture do not have helium and fill its airships with Hydrogen instead, then things get interesting. I recommend reading up to what happened to the Hindenberg for a good example.
Thus storing and using gunpowder based weapons on an airship is seen to be highly dangerous and undesirable. The alternative: Steam weapons. We've seen these things in movies and comic books.
A steam powered machine gun may be a good idea if mounted on an airship or vehicle, but you will never make them practical enough to be man portable. Contrast this with modern firearms: A modern firearms has the advantage of using cartridges, in which both the projectile (bullet) and propellant are housed together as a single unit in a very convenient package. with a steam powered weapon, the user must carry both the weapon and projectiles (say in a magazine), and a backpack containing pressurized steam (to propel them at any speed that is practical enough to use as weapons). These things will be heavy, cumbersome, and not able to fire a whole lot of times.
Therefore, its logical to propose that close range military action (say boarding an enemy airship) will still be done using cutlasses and pikes. With high ranking officers having a gunpowder handgun or two. Support fires will be provided by crew served mounted steam powered weaponry.
I suppose you can make gunpowder widely available to land based artillery forces, but they are very specialized and not available to the wider military/public.