Let’s assume the extension actually does a check to see if the compiler is available. In that case, providing it with the compiler in the environment you are running the extension might solve the issue.
So maybe try adding the dafny compiler to your system? Or run the whole combination inside a nix shell?
Other than that, if I see correctly, these VSCode extensions use stdenv.mkDerivation just like other normal derivations would. There you could provide a list of buildInputs which should be available at runtime. In your case the dafny compiler.
Currently in my configurations i just have the following without my other packages included for brevity:
environment.systemPackages = with pkgs; [ vscode.fhs ];
I do have a home module I was trying to setup that I did not get to. This is making it system-wide so I am guessing you can try nix-shell -p vscode.fhs, if you just want it temporary.