uhm.. this is a tough one. ok. While you could have held back with the yelling before, don't let yourself fall into the trap of feeling terrible about what you did and so giving your kids the earth to make up for it.
My advice to you is:
While your son is calm, and not saying he hates you, take him to a quiet room (if not already in one) and gently explain why you tell him off. Sit down with him, not far away but not squeezed up next to him. Explain that it's important you show him what's right and wrong in the world just for safety reasons, and his well being. You can apologise to him for shouting before. If he has anything to say, listen to him - AND DO NOT INTERRUPT - and react appropriately. For example, if he says "I hate you and you don't really mean that" you can say something along the lines of " tell me why. Give me every reason why you say you "hate" me. I promise to do what I can to make you happy. It makes me so sad seeing you so sad." If he requests chocolate or something similar, explain that that is a special treat, and if he helps you with the shopping, for example, he can have a little bit
BIG NO NOs
NO EMPTY THREATS - don't threaten him with a punishment then not follow through
DON'T BREAK PROMISES - this will only make him trust you less
DON'T YELL AT HIM JUST BECAUSE YOU FEEL LIKE IT - this will just take you back to square one
If you feel it's necessary, you can try getting someone at his school (or outside of school, it doesn't really matter) to have chats with him to get whatever's bothering him off his chest. Ask him if he wants to keep this private, and if he does, KEEP IT PRIVATE
Also, talk to his teachers (without him knowing, ideally) to keep an eye out for him to make sure he's not being picked on at school.
After talking with him, try asking him for a cuddle, and if he doesn't want to give you one, just say "ok, that's alright". I have a cousin that used to hate cuddles and so we'd just do a thing where it was like a high five but then we kind of held on afterwards (the whole family did this). Don't push him too much.
One last thing - try to join in with something he's doing for at least 20 minutes each day. If he likes Lego, for example, offer to do a kit with him at the weekend. But give him space if he wants to be alone for a while
Hope you are able to talk things through with him. You are not a "shit mum", as you put it.