"I'm sorry for avoiding you."
I would then proceed to explain why I did it. I'd admit my wrong doing and ask if we could be friends again. Usually, this would be enough. If is not, I would ask how could I make it up to them.
If they refuse to forgive, then I would just tell them to contact me whenever they feel they are ready to forgive.
It really matters on how bad the situation is, though. Like if is something that you really ****ed up, then you can understand why they would be so angry.
If is something that is not too bad, then you really should question if you want a friend that won't forgive you for some simple mistake.
If it's a case where I was totally in the wrong, I'd just admit to my wrongdoing, and make sure they know I wouldn't apologise and give them the time of day if I didn't care about them. I might try to do something for them too, like male a gift for them. This all applies to both offline and online friends.