If it is an environment variable, I would set it up in os.environ
before importing the module:
import os
os.environ['GDAL_LIBRARY_PATH'] = '/home/user123/lib/libgdal.so'
from osgeo import gdal
print(gdal.VersionInfo())
Mind you, this doesn't really do anything at all, since osgeo.gdal
does not use this environment variable in any way. Django, however, uses a setting with this name.