After some tests, it looks like the problem happens with the PowerShell version installed in the mcr.microsoft.com/dotnet/sdk:8.0.404
image (and all the other dotnet 8 images that I tested). The exact PowerShell version is 7.4.6.
I'm not sure if the problem happens because of the PowerShell version or the way it's installed in the image, but everything works like expected in dotnet 9 images or when installing PowerShell manually in a Debian bookworm container.