That's why it's called copyright. You can perfectly sign it away.
In Germany the right is called "Urheberrecht" which literally translates to "author's right". And while you can license your work and sign away the usage, you cannot by definition sign away the fact that you are the author of a work.
So how does ghostwriting work then? Lots of books have unaccredited ghostwriters.
In English this is usually translated as "moral rights"[1]. They are fairly widespread in other civil law jurisdictions than Germany too. Less so in common law jurisdictions.
But they exist to a (very) limited extent even in the US.
https://en.wikipedia.org/wiki/Moral_rights