In general, be polite but write as if you were talking to an actual, normal, nice person.
Your request should include some brief information about your motivation, the scholarship, its requirements, and how they apply to you. It should also help the recommender to recall who you are. And you should ask for a strong letter. If the recommender doesn't think they can write a strong letter, consider asking someone else instead of requesting a letter from them. I've highlighted those keywords in my example below.
Also, the supervisor is a good person to ask for a recommendation.
Dear Dr. X,
I am currently applying for the Donald Duck scholarship for graduate students in the field of comparative quackery.
I am aware that you only know me from the course on boat programming, which I concluded with a paper on applied quackery, but I was wondering if you were able to write a strong recommendation letter for my application.
As you may recall, I would like to continue my work on applied quackery in my MA thesis and include some comparative elements.
The scholarship is quite competitive. It is only awarded to students who are expected to be part of the best 5% of a school's cohort. The Duck family's mission is to promote candidates with a rounded education, so it might be of interest that I am taking extracurriculars in ancient philosophy and volunteer as rugby coach at a school in my neighborhood.
I would be extremely grateful if you could write a strong letter of recommendation until 15 January 2019. The letter must be submitted online at www.duck-quackery-studies.edu.
Please let me know if you think this is possible, and if you have any questions.
Depending on the local culture and the relationship to your supervisor, you may want to be less formal than this. But a letter like this would work also in Germany, which has a rather more hierarchical and less easy-going culture than, say, the US.