If you are running Big Sur or later versions of macOS, see this easier and perfect answer:
How to type ő and ű on a german keyboard
Else these 2 characters ő and ű aren't accessible from the German keyboard.
The easiest way for you to type them is to open
> System Preferences… > Keyboard, then click on the [+]
button on the bottom left to add the Hungarian
keyboard.
And select Show input menu in menu bar
so as to be able to switch when needed from your German keyboard maping to the Hungarian
one.
Then when you will need any of these 2 characters, just select from your new drop down menu the hungarian keyboard:

Next select also Show keyboard viewer
:

And with this keyboard you will find directly accessible all the hungarian characters you may want:

Once you have been able to type all the hungarian characters you might want, just switch back to your German keyboard. And just close the keyboard viewer