TL;DR: Apologize, always. Use feeling words in your apologies, own your actions, identify with your child's feelings about it, and tell him you're working on being a better dad to him and a better person. Then work on anger management by understanding how emotions work.
This is a difficult question requiring a long answer, sorry. It's not meant to attack you; I had to work on this as well.
Guilt that you feel spontaneously when you've done something you know is wrong is appropriate, and you should feel it. It's a good sign that you do. It means you can empathize with the child you lost your temper with.
Emotions are complex things, and often they are not what they seem superficially. Learning about emotions, primary and secondary, their labels, examining your own emotions carefully, identifying primary and secondary emotions, and teaching your child the language of emotions will help both of you, a lot.
Primary emotions are the very first thing you feel in a given situation. Sometimes they are obvious and recognizable to us (like joy or surprise) and sometimes they're not (like helplessness or inferiority). To recognize primary emotions requires a degree of openness and vulnerability, especially to the painful ones. Secondary emotions are what you feel after the first emotion. You can't control your primary emotions, but you can change the way you react on feeling the secondary emotions. (Sometimes, like with joy, the primary emotion is the same as the secondary emotion.)
An example: a friend jumps out from hiding and startles me. I instantly feel fear (or surprise). Fear is a primary emotion. I can't control it, I can't help feeling it. How I "react" to fear (it's a bit more complicated than reacting; it's a feeling as well, and it registers on my face) is a secondary emotion, and that emotion depends on who I am, my present emotional and physical state, my past experiences, etc. If my brother did it maliciously all. the. time., my secondary reaction will be anger, annoyance, or some other negative emotion, even rage. If I was in a good place emotionally at the moment, or it's a joke I understand or not something done to annoy me previously, my secondary emotion might be amusement. You can't control primary emotions, but secondary emotions can be modified with work.
Anger is more complex. Though some psychologists call it a primary emotion, others call it a secondary one, because it usually is. I understand it and experience it as a secondary emotion. Anger is a feeling resulting from something painful to us. Why do we swear when we hit our thumbs with a hammer? Because it hurts, and it could have been prevented with care, so we are angry.
Some primary emotions are just as painful as, or more so than, a hammer to the thumb. Feeling insignificant is painful. Feeling slighted, less than, helpless, confused, intimidated, unwanted, disrespected, and a bunch of other things is painful. Painful emotions are difficult to handle. For that reason, before we even realize it, *they cause a secondary emotion: anger, anxiety/fear, sadness or others. Anger is a common one, and is easier to handle than pain because it redirects that discomfort outward towards someone/thing else; it feels like power, it energizes. It's a 'solution' of sorts to our pain.
Parents get angry at their kids for all kinds of reasons, usually in response to a painful primary emotion that's difficult to handle in the moment. Setting aside justified anger, an example: my young child has an ear infection. She wakes up frequently at night, interrupting my sleep. I'm tired. She's cranky and demanding, which is draining my energy and my patience. When I try to give the child her antibiotic, which tastes terrible, the child justifiably fights me. I get angry with her. Why?
My reserves are down. Additionally, I feel helpless, hopeless, and afraid (all painful primary emotions I can't control), because she's ill and giving her an antibiotic is, I believe, the only thing that will make her better. I desperately want her to get better (for both our sakes!). Helplessness and hopelessness are incapacitating, so it quickly elicits my secondary emotion: anger. Anger is directed at an identifiable target: her behavior/her person. I feel enabled. I feel power to do something. I yell. I say mean things. I make excuses for my meanness; I blame her. And when that anger passes, I feel guilt and shame, both of which also hurt, not to mention the many painful feelings my child, who depends on me for comfort, safety and love, is experiencing. It's all just horrible.
The answer to anger is to cultivate calmness and to recognize/be open to feeling helpless, hopeless, fearful, and every other painful emotion. It's better than emotionally hurting your child.
What would success look like? Same scenario, and child spits out the medicine I tried to bribe, then force, her to take. I'm angry, but I do nothing for a moment and try to identify the feelings I had before I felt angry. Contemplating the pool of medicine, I realize I feel helpless, hopeless, physically tired, and fearful for her health. I say, "I'm so tired, honey, and I want so much for you to get better. You must take this medicine, even though it tastes bad, or I'm afraid you will get worse. Can you try again?" ("Pinch your nose/here's some juice to wash away the flavor/then we can watch a movie together, do you want ice cream or popcorn?"/whatever else might be helpful.) "I don't want to force you, but you will not win this one. You need to take this medicine, now or in 5 minutes, no exceptions."
This course of action shows love for the child, empathy and respect for her feelings, and outlines the situation. It also teaches her that you have feelings, too, and that feeling pain, fatigue, helplessness and fear is normal and nothing to be ashamed of. It doesn't harm her in any way.
That's really the answer. You were under a lot of strain, and have been for a while (I suspect quite a while, intermittently at least): you were taking care of a sick, cranky child by yourself, and you were fearful for your child's health and feeling somewhat helpless to protect them when he is with your wife's family. I mean, what's going on that he gets sick so often? What are they doing??? He just got out of the hospital with a UTI for @!#&^$#{} sake! And he's still sick! This is so. stinking. HARD! [And you live with that right there in the moment. The more you do this, the easier it will become to rest with your primary emotion(s) and not to get angry/other harmful emotion. Really. It's hard work but the benefits are immense.]
There are a lot of answers on this site detailing the benefits of teaching your child empathy, emotional literacy, resilience, etc. Search the site and read them. There's less about self-care as a parent. Read about that too, wherever you can find it. Read about anger management, how to apologize meaningfully, how to turn guilt and shame into a learning experience, and finally, how to forgive yourself and how to ask for forgiveness. Don't worry about appearing weak. Worrying about how others perceive us is a recipe for unhappiness. Figure out what you can do (why he gets sick so often) and do what you can about it. (Keep records, too; you may need them.) And please know that we all fail our children, and that asking for help and working at being better is the right response. Good luck.
What’s The Difference Between Primary And Secondary Emotions?
Unconscious emotional processing
Control anger before it controls you