Guilt is an unpleasant emotion - does it have a use?
I think - sometimes.
Sometimes guilt signals to us that we haven't behaved in line with our values. When I am functioning well, my response to a feeling of guilt is to realign my behaviour with my values and then work out how I can make amends. It could be making a sincere apology; doing something to 'right the wrong', or, if it wouldn't be appropriate to address it directly with the person involved, then do something that I feel balances out my 'wrongdoing' - perhaps do a favour for someone else or give to a charity. For me making amends is important - it means I find it easier not to buy the thoughts my mind will often scold me with when I have made a mistake. When I am not functioning so well, I can get hooked by those thoughts and become anxious and frozen.
At other times, guilt signals to us that we have broken a internal rule that isn't relevant for us any more. Something we were taught in childhood about how we should behave that doesn't align with our adult values. It could be about what we wear; what we eat; who we sleep with; or even as simple as asking for what we want in a relationship. In those circumstances it is a pretty useless emotion. The trick then is to notice it with curiosity and compassion. I don't recommend battling to get rid of it. Just make some space for it. Acknowledge the child within who was taught that rule and perhaps feel grateful that as adults we can choose our values.