If your handy with a soldering iron you can replace the battery.
The key fob takes a Panasonic ML2020 or VL2020 battery.
Brand New PANASONIC ML2020 VL2020 Battery fits BMW E46 E60 E90 Key Fobs | eBay
You need to carefully separate the front and back covers of the key. I did 2 keys using a putty knife. Start from the key ring and then work your way around the edges. You want to keep the knife blade on the perimeter of the key other wise you could damage the circuit board. It should open up fairly easily. Desolder the old battery and solder in the new one.
To reassemble the two halves you can use some plastic epoxy which should provide a water resistant seal. Or you can get silicone key fob covers. Since my 2 keys are backups I just put a strip of duct tape on each side to hold the key together and put the cover on.
Silicone key cover protection case for BMW X3 X5 Z3 Z4 3 5 7 SERIES E38 E39 E46 | eBay