This does not work and is not currently supported by Spine.
I believe this is the issue where it is tracked: https://github.com/EsotericSoftware/spine-runtimes/issues/1676
Basically what happens is that this way you don't download the spine-csharp code which is currently not supported as a UPM package and is not located inside the path you have proved in the github url above.
Note that this works for timeline and urp-shaders packages (I guess it works for lwrp-shaders too, but I haven't tested it)
This is exactly how I use this for them (part of Packages/manifest.json):
"com.esotericsoftware.spine.timeline": "https://github.com/EsotericSoftware/spine-runtimes.git?path=spine-unity/Modules/com.esotericsoftware.spine.timeline#e3214889495b51818fb9fbf03ee5659b02faed79",
"com.esotericsoftware.spine.urp-shaders": "https://github.com/EsotericSoftware/spine-runtimes.git?path=spine-unity/Modules/com.esotericsoftware.spine.urp-shaders#e3214889495b51818fb9fbf03ee5659b02faed79",
By the way, when (if) this method becomes available for spine-unity too, I would recommend against using a #4.0 version but to use a hash of given commit. Otherwise you might get hit by nasty bugs on one instance of the project (ex. on one computer), that are not presented on another instance (another computer), simply because they downloaded the package at different point of time which could result in different version of the packages.