It can be prepared by mixing alcohol (18 parts) with a solution prepared by action of concentrated nitric acid (60 parts) on mercury (1 part). The solution is slightly heated and maintained below 60°C. After a couple of minutes a reaction happens that heats the solution.
The fumes should not be breathed since they are toxic. Soon, mercury fulminate precipitates. The product has to be washed with water until no trace of acid remains. The manipulation of mercury fulminate is quite safe, provided that it remains humid.
Silver fulminate can be prepared in a similar way, but this salt is even more violent than mercury fulminate. It can even explode under water.