capacitor bank as power source for UPS
Capacitors store energy so, yes, you could replace the batteries with a capacitor bank.

To size the capacitor bank, you'll need to specify the required energy for the 5 second interval, which you haven't done, as well as the allowed change in voltage across the bank.

The energy stored in a capacitor is proportional to the square of the voltage across.  Thus, as the capacitor bank discharges, the voltage will decrease.  So, you will need to specify the voltage at the start and end of the 5 second interval to properly size the capacitance.

However, I think you'll find that the cost is far, far greater than for batteries.  See this for example.