I read on the internet that the thumb should never play the black keys.
It is perfectly all right to use the thumb on a black note (there, now you have read it in the internet!).
Yes, there is a general principle that advises to avoid the thumb on black notes. But why? Unless you can answer this question, it becomes
superstition and you will not know when to use the thumb on a black note, and when it would be preferable not to. I suggest you investigate this matter (and remember that J.S. Bach was on of the first keyboardists to use the thumb at all – one generation before only fingers 2-3-4-5 would have been used).
In the sonata you provided the score in particular, there is no way you can avoid using the thumb in a black note without incurring some major contortionism/discomfort.
You can read more about using the thumb on black notes here:
https://pianoforum.net/smf/index.php/topic,5055.msg48120.html#msg48120(fingering for sinfonia no. 9)
I also got a problem with Minuet in G, but it's also: where should the fingers be. It's in the G minor scale (G A B C D E F#) and I think the walking is 123 1234 (just like C major), but it feels weird that way.
Should I always use this fingering method or should I just do what feels best?
As for the “G minor scale”, I believe you mean G major. (G minor is G-A-Bb-C-D-Eb-F#-G). If you had G major in mind, the best fingering for the right hand is indeed 123 1234 (just like C major). However for the left hand you will do far better to use 321 321 4 (try to use a fingering that always uses the 4th finger on a black key) instead of the usual 54321 321.
You can read more about scale fingerings here:
https://pianoforum.net/smf/index.php/topic,2313.msg19807.html#msg19807(Speed of scales – the important factors in speed playing - an alternative fingering for scales).
https://pianoforum.net/smf/index.php/topic,2619.msg22756.html#msg22756(unorthodox fingering for all major and minor scales plus an explanation)
And about general principles of fingering:
https://pianoforum.net/smf/index.php/topic,2458.msg21365.html#msg21365(Mental practice – tips for fingering)
https://pianoforum.net/smf/index.php/topic,2749.msg23873.html#msg23873(self-teaching – the pitfalls. Analogy of frying an egg - principles of fingering)
Best wishes,
Bernhard.