Can I charge an iPhone XS from my Macbook Pro 2015 when my MBP is running on battery?
Yes.
You can charge your iPhone via your MacBook irrespective of whether it is running on battery or power.

Yesterday when I plugged it in, the iPhone wouldn't charge from my laptop.

It could be possibly be due to a faulty cable or port. Try cleaning the port or any dust or other accumulation and/or switching to a different port. You can also try connecting a different peripheral or device to ensure that the port is in working condition.