You don't, really.
And the reason for that is that while the environment variables are passed to the program when it's executed (the same way command line arguments are), after that they're just some table somewhere in the memory of the process. You can't modify them from the outside, from a another process, because in general you don't know where they are.
The C library keeps a pointer called
environ, which points to a table of pointers to the values that are together called "the environment". The location of that table might change if it needs to be reallocated during the lifetime of the program, and the locations of the values would similarly change.
environ pointer itself would live in the same location for the time the program runs, so you could plausibly hack the values, provided you find the pointer. Stuff like address-space layout randomization would cause it to be in different locations in different program invocations. Even if you were to find it and change the program's memory, you can't tell if the program copied the value (or a pointer it) somewhere else and used it from there. Like stuff from a configuration file would be copied to some place within the program memory.
On the system call level, the environment doesn't even get automatically copied across the execution of a program, since the environment values have to be explicitly passed as an argument to the
execve() system call, and the table passed there doesn't need to have any relation to what the executing process calls its
All of that also means that what e.g.
/proc/$pid/environ shows in Linux might not correspond with what the
getenv() system call returns within the program. (I think the file shows the area of memory that was used to pass the values when the program was executed.) The idea of there being "the environment" as some special data structure is not exactly right.
To modify the configuration of a running program you'd need support from the program itself, it'd need to be able to reload the configuration from somewhere. Or at least support from its parent, which could reload its configuration, and restart the child to pass it another set of environment variables.