For example, in a circuit with a battery and a capacitor, KVL cannot
be applied.
Yes, in fact, it can.
In fact, the voltages and current asymptotically approach the values
predicted by KVL as the capacitor charges.
Then there is more than just a capacitor and battery in the circuit.
First, to be clear, KVL is an approximation that is exact in the limit of ideal circuit theory.
Now, KVL applied to an ideal circuit composed of a battery and capacitor yields the following equation:
$$v_C = V_{BAT}$$
So there is no time dependence; at all times the capacitor voltage and (constant) battery voltage are equal.
For a physical circuit composed of a physical battery and capacitor, one must not forget to include additional ideal circuit elements to model the non-ideal characteristics of physical circuit elements.
For example, if we assume the circuit has not existed forever, there must be a switch to model the fact that, at some time, the capacitor is connected to the battery.
Also, a physical battery cannot supply arbitrarily large current and, in fact, can only supply a finite current when short-circuited. Thus, we must at least add an ideal resistor in series with the ideal battery to approximate a physical battery.
Since the physical wires connecting the battery and capacitor have non-zero resistance, this resistance may need to be modelled too.
In some cases, we may need to model the non-zero inductance of the wires etc. but, let's assume that we can safely ignore that and any other non-ideal characteristics for this particular problem.
Now, the KVL equation for this ideal circuit model of a physical battery-capacitor circuit is (when the switch is closed):
$$v_C = V_{BAT} - i(R_{BAT} + R_{WIRE})$$
Taking the time derivative of both sides and multiplying by the capacitance C yields:
$$C\frac{dv_C}{dt} = i = -\frac{di}{dt}(R_{BAT} + R_{WIRE})C$$
for which the solution is
$$i = i_0e^{-t/\tau} $$
where
$$\tau = (R_{BAT} + R_{WIRE})C$$
and
$$i_0 = \frac{V_{BAT}}{R_{BAT} + R_{WIRE}} $$
is the current immediately after the switch is closed at $t = 0$.
Thus,
$$v_C = V_{BAT} - i_0(R_{BAT} + R_{WIRE})e^{-t/\tau} = V_{BAT}(1 - e^{-t/\tau}), \, t\ge 0$$
So, in fact, KVL does give the correct equation predicting the capacitor voltage.