How to politely decline the university medal?
The problem is as @WetlabWalter says: the medal is not just for you - it is for everybody that supported you and, in fact, indirectly for your class, and lecturers.
You have a good reason (for yourself) to decline it, which is commendable.
But you might offend those who recommended you, those who taught you (who would be indirectly honoured) and possibly your classmates.
If on weighing your principles against this you still stand by your decision to decline the prize, send a letter as long beforehand as you can, explaining your position and emphasise your history of declining prizes (to indicate that they are not the only one on the receiving end of the rejection).
Don't decline on the event itself, this will be a major embarrassment.
Finally, if you develop a reputation for declining prizes, grant managers may decide that they'd rather not put glamourous, funded programs your way, so be prepared for limitations of funding in the future. For anybody as brilliant as a Grothendieck or Perelman, that should not be a problem, but if that's not the case, take that into account.
PostScriptum: The balance of prize distribution is very fine. A prize is supposed to honour the recipient. But if the recipient is absolutely outstanding, the recipient would add as much glamour to the prize as the other way around. Therefore, a rejection penalises also the prize-giver.
Why are prizes at all relevant? You have a point in that a true scholar should not be motivated by prizes and honours. However, in today's very crowded fields, a prize is like a flag that demonstrates "this is how things should be done". It sets a signal of example for others. By rejecting the prize you send the message that you do not care to be an example; which is entirely your right - but you must be aware of that.
Interestingly, Sartre was one of the few people declining the Nobel prize (literature). It was claimed that, some years later, he decided that he'd rather be in need of the prize money and asked whether he could get it retrospectively (after this story, he couldn't). Whether this anecdote is true or false, it makes clear you have to think hard whether there could be a constellation whether you could regret your decision - it doesn't have to be for the money, of course.
Get over yourself.
This isn't about you. And this isn't really even about your work. This is about a community celebrating its own values, by recognizing the individuals that best represent those values.
"True scholars" don't exist in a vacuum. We are part of a community of scholars. We use resources created by that community, most obviously in the form of the work of our predecessors ("shoulders of giants"), but more indirectly through the efforts of colleagues, teachers, students, advisors, committee members, letter-writers, department chairs, librarians, referees, editors, conference organizers, and funding agencies that make our work possible. We owe that community an incredible debt. Accepting recognition gives you an opportunity, which most people never have, to display the gratitude that you owe that community.
It's noble and selfless not to pursue recognition, but by actively declining recognition, you are making a clear and public statement that the offered recognition—and by extension, the community that offers it—is either inappropriate or beneath your notice.
If you actually believe that the university has selected you inappropriately, either through incompetence or malice, or that the ethical and intellectual standards of the university are so compromised that you don't want to support them, then of course you should refuse the prize. Otherwise, refusal is simply selfish; the appropriate response is to accept the recognition with humility and gratitude, and then get back to work.
Let me add a response to a specific comment by @CaptainEmacs:
As a scientist, all you agree to is to join a scholarly activity, and publish, and, if your head of department squeezes you, gain grants. Some introverted people or people from "introversion"-primed societies really do not want the extra attention from a prize.
I respectfully disagree with the first sentence. Becoming a scientist entails more than just doing research and publishing the results of that research. We also have an ethical obligation to evaluate our colleagues' work (because they evaluate ours), to write recommendation letters for our students and junior colleagues (because our advisors and senior colleagues have written them for us), and to make our work visible (because we work for the benefit of the community, not just for ourselves). And yes, I believe we have an ethical obligation to help promote our communities/organizations/subfields, because we have materially benefited from others' promotion of our communities/organizations/subfields.
Yes, I understand agree that some people really do not want the extra attention from prizes. For similar reasons, some people really do not want to submit their results for peer review, or really do not want to present their work to a live audience, or really do not want to write grant proposals to obtain the necessary resources for their work. But sometimes we all have to do things we really don't want to do.
The discussion here about your question provides an interesting microcosm of the sort of responses you are likely to get to your decision to decline the medal from people at your university who learn about it. Already here we are seeing a lot of people who don't even know you telling you to reconsider your decision, implying that you have a moral duty to accept the medal as a service to the university and to the other students who ostensibly are meant to be inspired by your excellent academic performance (which seems like a very weak argument to me personally), and offering other kinds of unsolicited advice that doesn't answer the specific question you asked. I sense in these responses a fair amount of indignation and possibly offense, and I think it's interesting to try to understand what is causing it.
My feeling is that what's going on is that for most people it's hard and even offensive to see someone turning down a great honor or privilege that they themselves would be happy to have and maybe can only dream of achieving. It feels to people like a waste, like seeing something very valuable being casually thrown away, or like seeing a rich person lighting a cigar with a $100 bill. As much as people may be able to understand your reasoning at an intellectual level, at the emotional level it feels that not accepting the medal is an act of condescension on your part, as if you are saying that you are so much better than everyone else that you don't even need earthly benefits like awards or medals to feel superior.
With this analysis in mind, let me answer your question. If you have indeed decided not to accept the medal, there is nothing you can do other than to explain your decision and the reasoning for it to the people at your university as clearly as you can, just as you explained it here. You should fully expect that some of them will be offended, and some of them will try to convince you to change your mind and offer the same kind of advice and moralistic arguments that are being offered to you here. I don't think that can be avoided, but I don't necessarily think that it needs to be avoided either. I have great respect for people who follow their beliefs at the risk of being unpopular or angering others and would like to encourage you to ultimately do what you think is right, after carefully weighing all the relevant information. Good luck!