Wikipedia says:
"Mercury(II) fulminate is prepared by dissolving mercury in nitric acid and adding ethanol to the solution."
So I'm guessing that the dwarves may already have it- Mercury and ethanol we've already seen on screen, and nitric acid (HNO3) is apparently used to identify low-carat gold, so I'm guessing the dwarves have it too. Looks like you can get it with some low-tech processing of copper salts:
"In the laboratory, nitric acid can be made by thermal decomposition of copper(II) nitrate, producing nitrogen dioxide and oxygen gases, which are then passed through water to give nitric acid."
Given the way mercury fulminate apparently degrades over time though, I can see dwarves avoiding using it in weapons.