This exact question was just asked in the last few weeks, and if you search "giving child medicine" you will find many more. Most of these have to do with infants and toddlers, but you'll find plenty (like the recent one) that deal with older kids.
You can't get into a wrestling match with a child. Eventually, he will be too big for you. Yes, you can hold down an infant to change a diaper, but a 5 year old needs other techniques. And, you will face things like this when he is 10. And 13. And 17, wanting the car keys.
You don't strong-arm a child or a teen. You simply wait until they want something. Which is about 10 minutes. They want screen time, snacks, a play date, a ride, etc. If you have to get out the door to go to school and he needs the medicine first, for example, you tell him you'll wait until he's ready. You'll also remind him that late arrivals don't go directly to class, but hey go to the principal's office to report in (school rule, not yours). So when he misses the bus and you have to drive him (which will be when you are good and ready - because nothing horrible happens if a 5 or 9 or 11 year old misses an hour of school), then he will go to the office and get to explain to the principal why he doesn't think school is important and why he thought it makes more sense to have a tantrum over medicine, why he thought 5 seconds of being a big kid about health was less important than seeing friends, having fun and learning stuff. You have to say this with no judgment in your voice, just total calm and businesslike tone. The idea is, this is unfortunate for him, rather than a big problem you're going to get agitated about. He's getting off on the dispute and the drama, so you have to take that out of it.
Make this about his choices and not your demands. If he chooses not to watch TV or play on the computer, not to see a friend, not to ride his bike, not to go to recess but to have to stay inside to make up the work he missed, not to do anything but sit on his bed until he's ready, fine. His choice. But those privileges are for big boys who are responsible, not for kids who aren't yet ready. If he won't take care of his own body, then he's not old enough to be trusted with a remote, a computer, a mouse, a bicycle in traffic, or anything else. Pick the thing most "valuable" to him now. Don't list all the things he's not going to do. Just one. If he gives up on that one thing and asks for something else, your answer is still "No, that's for big kids."
This may make you late for work one day or delay you in other things, but then that's the consequence for him. There was no time to pack dessert in his lunch or pick up snacks at the supermarket because you had to spend time waiting for him to take medicine. Do not scramble to make up the time you lost waiting for him - just eliminate something that mattered to him. See how it works? You just have to be willing to make the first step.
This technique will work well into high school. The sooner you master it, the easier it will be for all.