The community-accepted solution for including a shebang line for Python seems to be to use #!/usr/bin/env python3. However, when I install Python 3 using the winget package (i.e. winget install --id Python.Python.3.11), and then attempt to run a script with the shebang (i.e. py some_script_with_shebang.py), I get an error:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
> Manage App Execution Aliases.
Through investigation, I found that I can install the msstore package to resolve this (winget install --id 9NRWMJP3717K, and where python3 returns %LOCALAPPDATA%\Microsoft\WindowsApps\python3.exe). However, I don't know why I need to install the msstore version (with the opaque ID), rather than the winget package (with the transparent ID).