I got it working.
The documented requirements for Unreal Engine with VS Code is missing the information that some additional components have to be selected in the Microsoft Build Tools installation:
- Windows 11 SDK
- .NET 7.0 Runtime
- .NET SDK
- .NET Framework 4.8.1 SDK
- MSVC VS 2019 C++ Buildtools

They are not installed by default.