Can I get my battery replaced under the factory warranty?
on 2009 Mercedes-Benz C300 4MATIC

my car is still under warranty

I doubt it because it seems like your battery might be 4+ yrs. Also batteries are maintenance item. I would say ask your regular independent Automotive Service Facility and have perform a battery/charging analysis to see what is cause of your vehicle malfunction. Best of wishes.