I shot the publicity pictures for the European Firework Championships held in Plymouth each August. I did it on film, but the method is the same whatever storage medium you use. You can use the lens cap, your hat, anything to block the light to the lens.
You don't need to layer and compose the shot - do it in camera with one balanced exposure. Then wind on and shoot another.
You want ISO 100to get best quality. Shoot RAW. Use f8 as your starting poin, and leave the shutter open (use bulb and a cable release if you have one - otherwise try the TIME position....it uses less power).
You can count for the shutter speed - but we are talking several seconds build up.
At f8, get a reading for the castle and its floodlights - you can get away with nearly double because of reciprocity failiure. This is so you don't burn them out. That will give you a shutter speed (shutter open time) so you don't burn out the castle lights.
All you do is LISTEN for the first bang...take your lens cover off, whatever it is, lens cap, hat, hand.....and count while that firework explodes. DON'T watch the fireworks, concentrate on making your pictures, otherwise you will get out of synch.
As the firework bursts, as soon as the burst finishes, cover the lens. Wait for the next one and do the same ON THE SAME FRAME. That is why you leave the shutter open - with your hand/hat/lens cap in front, the shutter may be open in the camera, but your makeshift one in front of the lens is closed, so no light is getting through to the "film" so you are not recording anything.
As the next one goes up - take your lens cover away and count again. You can get away with f8 and 2 secs at 100 speed.
Next shot try f11 and giving more exposure time - more firework bursts.
Go and practise on the castle BEFORE the evening of the display....the floodlights will be the same. You will get your best shots on the earlier firework bursts, while there is some light left in the far sky. When the sky is still a little bit purple. Once it goes inky black the effect is not nearly so dramatic.
To find out how to do time exposures on YOUR camera - read the manual on that section.