I’m pretty sure you need to use “exit” instead of “return” in a PowerShell script to set the errorlevel. How you use “return” in your script probably just outputs the numeric value to the screen, which isn’t the same thing.
Also you should set the errorlevel to 1 if you want Duplicati to not run the backup and not produce a warning or error message. (See this post for more info on that.)
Set --run-script-before to be the full path to your PowerShell script, including the .ps1 extension.