Is there a way to have my macbook set its brightness based on it running from battery or from line power? Basically I'd like to have one brightness setting configured for when I'm plugged in through the adapter and charging the macbook from wall power, vs a lower brightness setting when I'm running off battery to preserve battery life. This configuration swap would be in response to the changed power state of the laptop. Does MacOS support such behavior?
While macOS does not support the exact behavior you are looking for (setting custom brightness when switching between power states), you can configure your Mac portable to slightly dim the brightness automatically when on battery power.
To do that, go to System Preferences → Energy Saver and enable Slightly dim the display while on battery power.