how to change install location of "winget"?

This feature is proposed in Can the software installation path be set? #489.

The answer on Jul 11, 2020 was:

There is already a function in Winget, use winget install Software.Name --location "C:\Folder\Software.Name"

However the support is limited right now.

BUT, we also just got support for Interactive mode winget install Software.Name -i, which is a safer option then --location right now.

The location option is new and is likely to have bugs, and it seems that you have found one.

The best solution is perhaps to wait for this to be fixed, and to add a bug report to https://github.com/microsoft/winget-cli/issues.

If the -i solution is not an option, you might as temporary workaround move manually the contents of the folder on C to D and replace the C folder by a symbolic link to the D folder.

For more information see The Complete Guide to Creating Symbolic Links (aka Symlinks) on Windows.