Yes, as with all things in Octopus, you can add scoped variables from the API using PowerShell. In fact, we have an example of adding Environment-scoped variables in our Api Examples repo here:
I hope this is a helpful example. Feel free to reach out if you need any further help with the script.
Thanks and Happy Deployments!