Most guitarist (and some bassists) who've ever played using a lot of volume, gain, or both knows all too well about that microphonic squeal that can plague a gig. So you end up rolling the volume back during quiet passages, although some squeal always ends up getting through. Listen to Randy Rhoads at the beginning of Crazy Train for a great example.
So what causes it? First you must make sure it's the pickup. Try your guitar with a different amp. If it's definately your guitar, make sure there's not some loose metal, such as a pickup height spring, that's not vibrating sympathetically. Your pickup will transmit that sound to your amp, and it sounds just like a microphonic pickup. If I eliminate everything else, I'll remove the pickup from the guitar, and wire it to a jack. Plug it into the amp, and adjust to normal settings. If it still squealing, then the coils are vibrating.
So do you just chuck it and spend $150.00 or more on new pickups? While I recommend being prepared to do just that, you can always try potting.
Pickup potting is simply using some substance to "seal" the pickup and prevent the coils from oscilating. Using wax is not difficult, and it's cheap. You could pot a dozen pickups with about $10.00 worth of materials.
There are some pickups that cannot be potted. Any that have already been potted with epoxy cannot be repotted, such as all variations of EMG, Shadow, and Bill Lawrence. Pickups that have been potted with lacquer will be very difficult, and generally will only show slight improvement.
Good candidates are pickups that come on imports. Epiphone pickups sound pretty good to my ears, as do the "Duncan Designed". Ibanez pickups are manufactured by DiMarzio's overseas manufacturing, and are not too bad either. Any pickup that you believe sounds good that doesn't fall into the categories in the previous paragraph are good candidates.
This customer has a set of Gibson 57 Classics. He loves the tone, but they are manufactured the way they were in 1957, with no potting at all. They squeal badly even with the moderate amount of gain he uses.

As stated before, you should be prepared to replace the pickups prior to attempting potting. The pickup can be damaged to the point of non-functionality, although I've never had one go bad during the process.
So here we go. You need the following supplies: double-boiler, parrifin wax, beeswax, dowel rods & rubber bands.
A double boiler is a pot in a pot. I don't have one, so I made one out of a metal coffee can. I drilled four holes, and ran dowels to support the can so it doesn't touch the bottom or the sides of the larger pan. The dowel on top is to support the pickup in the wax without it touching the sides or the bottom. The extra hole in the back is a drainage hole, in case I melt too much wax.

You use an 80/20 mix of parrifin and beeswax. The reason for the beeswax is parrifin by itself hardens too solid when cool, and can flake off. Beeswax keeps it flexible enough when it hardens to prevent that. I used 1 lb of parrifin, so 20% is 3.2 ounces. I uses probably closer to 4 oz. A perfect 80/20 mix is not imperative.

Fill the large pot with water. Fill it up as full as you can without the small pot floating, and turn on the heat. Your goal is 140 - 150 degrees. Anything hotter can damage the pickup. So turn the stove on low and give it time.
You can see what happens if you get distracted. I let the water boil, and the wax is 200 degrees. Way too hot!!! A pickup's plastic bobbins can melt at that temperature, as can the lacquer coating on the pickup coils. It took over an hour for the wax to cool to the correct temperature.

The water still looks like it's boiling, but it's actually wax which drained out of my extra hole.

I used an old guitar string around the dowel and through the screw hole to suspend the pickup in the wax. If the pickup has a cover, leave it on. Also leave the pickup tape on. What I didn't show is the rubber bands wrapped around the pickup. The pickup tape's adhesive will loosen at this temperature, so the rubber bands will keep it in place.
There was a rush of bubbles at first, indicating the wax was getting into the crevices just like we need. Let it sit for 15 - 20 minutes, but do not walk away! You need to monitor the temperature for the whole process. 150 degrees is the maximum.

And we have two potted pickups. Let them cool for about 5 minutes, and wipe the wax from the face of the pickup. Install them and see how successful it was. Keep in mind, if you're using a ton of gain, a lot of volume, and stand close to your amp, this does not guarantee no squealing at all, but you should have an immense improvement.

I offer this service for $10.00 per pickup if you're not comfortable with the process. Much cheaper than a new one.