how can I get rid of the previous phone number?
You can't use it in Germany.
Look for / visit a carrier, take a subscription, postpaid or prepaid card.
Checks whether the SIM card is suitable for your iPhone.
Then see this Apple article: How to unlock your iPhone for use with a different carrier
How to unlock your iPhone for use with a different carrier - Apple Support
Apple can't unlock your iPhone for use with a different carrier. Only your carrier can unlock your iPhone.
Normally (in the EU) after 2 years the consumer has the right to ask that the carrier unlock the iPhone.
When you have the new phone number, see :
Sign in to your Apple ID account page and edit / update your Apple ID details.
https://appleid.apple.com
-> edit your trusted phone number.