Really where? Certainly not in the United States and I don’t see any reason it should be illegal. Your an employee not a citizen.
See the "notice" section starting at bottom 3 of this for the lay persons summary on the notice requirement (or read the whole thing to see what laws around this look like in Germany) https://www.bakermckenzie.com/-/media/files/people/lutz-holg...