Updated: May 2
You can do it and here is how
Position yourself as far away from town lights as possible. I took all these pictures over Lake Grandbury (Texas). The goal is to have a black sky if possible.
Shoot on a tripod but be ready to swivel your camera and do slow loops and swoops. You'll need to really experiment, shoot a ton of exposures, and be prepared to delete most of them to get a few awesome shots.
Dial in the following settings on your camera (or phone): F22 (f-stop aperture setting), 15 seconds or "B" (shutter speed), 800 ISO (sensitivity setting).
Also, once the fireworks get going, set the camera to manual focus and focus on infinity. This is important; do not leave the camera on auto-focus. Doing so will cause the camera to constantly search for a focus point as bright lights are occurring.
Don't be afraid to zoom in on the action and try and fill the frame. Yes, you can crop later, but cropping can also make your pictures look not as sharp and clear. If you prefer, just put the shutter on "Bulb" ("B" on the camera means open shutter) and leave it open while you are making your exposure. The action will happen in front of your open lens anyway.
On some of your pictures, with your camera on a tripod, open the shutter (press the shutter button) let the camera sit still, gazing into the black sky as the action happens in front of the lens.
On some pictures, slowly rotate your camera in loops as the fireworks are exploding in the sky. On some pictures, zoom in and out and even pan across the sky slowly. The key here is to experiment, have fun and take lots of pictures.
You can also play with your f-stop settings. F22 is not fixed, but you do not want a wide-open lens. Remember, you are not taking a "snapshot" like you would normally, but instead you are allowing the fireworks to shoot off and explode in front of your camera. This is not video, but rather it is a time exposure.
As you are shooting, occasionally preview your images (pro photographers call that "chimping") to see where different settings and panning techniques work for you to create stronger images.
Below, I call this picture my "palm tree" photo. I was not moving the camera. Multiple fireworks shot off at the same time and created this montage effect.
Shoot fast, take tons of pictures, and have fun. Happy Fourth!