May I cite an unpublished exercise from a lecture? In a mathematics thesis I am currently working on, I use a statement we proved in the exercise classes of a lecture I attended last year, but neither the exercises nor the lecture notes have been published. I am wondering whether it is still possible to cite the exercise, and if yes, in what format.
You always cite your source as best as you can. If your best citation is “unpublished solution to a lecture exercise”, then that is what you should cite. If you can find a better citation, fine. If not, cite it this way. 

Since you don’t want to rely on something unproven, you should include the proof. One reason to have a citation is to allow others to verify the result, so the proof should be somewhere where I can read it. If there’s no other place than your paper, that’s where it should be. 

And to avoid accusations of self-plagiarism you should probably mention how the proof was created.