Create and set environment variable in MacOSX
In general, there is no one environment on macOS. Not all programs and not even all command line utilities respect the same common environment space.
On OS X - the launch daemon has been around and it spins up a sandboxed / isolated state for each app and each process, so you would edit into the preference / database entry for each process the variables it needs.
The current implementation would be to make a defaults write
to write whatever values you want to your "global environment" and than have each program read those preferences as part of their startup or refresh script.
I would encourage you to ask a follow on question since no one really wants to sign variables, they want to write variables so some programs can do something with them. Let's dive into what one or three programs would read what specific variable to do some thing and explore if you are stuck with making a modification to each one or could set up some sort of shared database or call to make those changes effective.