Yes need to drain oil to replace the sensor, you will have to drop the under tray to get at it.
Parts diagram and part numbers here https://www.realoem.com/bmw/enUS/showparts?id=BT52-EUR-06-2004-E85-BMW-Z4_30i&diagId=11_2187
Various brands available here go for a known maker prices vary
https://www.onlinecarparts.co.uk/oenumber/12617508003.html
Also available via ebay various makes and prices
https://www.ebay.co.uk/c/645199485
My sensor hasn’t worked for the past 2 years and tbh, it’s no big deal. Just check level every week or after a spirited drive.
Can’t imagine changing anytime soon as I suck oil out on changes with a pela pump.