Bad idea. A compressor will only decrease headroom. What you want is a transparent boost or EQ pedal that has the capability of achieving LESS than unity gain. E.g. -10 db setting. Kick that on in front of a dirty amp and that will help clean it up in a different way than just turning the guitar’s volume pot down.
Done it for over 20 years.
Set the pedal to compress how you want it to. After that, bring the compressor output down to get the desired amount of gain out of the amp. This will work just like turning down the guitar volume. The advantage is that now you have a much more controlled and constant volume going into the amp, if you set the threshold right on the pedal.
Turn the pedal off and you have the guitar on going into the amp at full volume and distorting it. Turn the compressor on and now you have the guitar signal hitting the amp very constant, but with a much lower volume, and the amp is lot cleaner.
Compression is probably the trickiest of the effects available since when it was invented, so, it's not easy to figure out, since it works with dynamics. But once you learn it, this is just one more of the infinite tricks you can do with it.