If you are rude to someone, firstly attempt to dilute your rude comment and depersonalise the impact. By depersonalising the impact you are generalising this to make sure the person knows the comment is not just about them.
Be respectful, ask for permission to speak first.
An example apology is: “I feel so foolish” (shows humility)
Then sincerely apologise with humility and take responsibility for the hurtful comment.
Casually follow up in private to see that they are OK with you.
By humbling yourself this demonstrates humility and keeps your ego in check.
Remember the apology is about the other person – not you.
Feel remorseful, stop the behaviour and show respect. Be accountable- don’t minimise your role or blame them.