I tried a lot of things, but nothing worked.
After I connected my PS4 with another ISP it worked without problems. It looks like, that the issue has something to do with the internet connectivity to the servers from Microsoft and the ISPs.
So if it still not works, simply try to create a WLAN access point with your smartphone (disable WLAN to your local router) and connect the PS4 with this WLAN. Start Minecraft and try again.
Yes, it is the same thing.
I found out that I am only logged out (and can't log in) when I use PS Remote.
If I use Minecraft directly on the TV (which I very rarely do), then I can log in.
Hope this helps a bit to solve the issue (and always using the TV is not a solution for me because my wife is not amused by it 😉).