Caplets as zero-bond puts
To simplify things, consider each caplet by itself, the value of the cap would be in that case the sum of the caplets' values.
So, let's take a single caplet on nominal $N$ and with strike $K$, Libor tenor $\delta$, expiry $T$ and payment date $T +\delta$.
If your pricing date is beyond the expiry but before the payment date: $T < t < T + \delta$ then the payoff is already known, and the value of the caplet is just the value of the flow multiplied by the zero-coupon bond:
$$
Caplet(t)= NP(t, T + \delta) \underbrace{(L(T, T+\delta) - K)^+}_{\text{already known if } t > T}
$$
If the pricing date is before the expiry, then the caplet can be written as a put option on the zero-coupon bond with strike $X = \frac{1}{1+ \delta K}$ (as explained here for example Cap option on Libor), leading to:
$$
Caplet(t) = \frac{N}{X} P(t, T) \mathbb{E}^T \left[ \left(X - P(T, T+ \delta) \right)^+\right]
$$
To price this option, a model is needed for the zero-coupon bond price.
Caplets pricing under Hull-White model
When the short rate follows Hull-White model dynamics with mean reversion $a$, and volatility $\sigma$, the zero-coupon bond distribution is lognormal:
$$
\frac{dP(t, T)}{P(t,T)} = r(t)dt + \sigma(t) B(t, T) dW(t)
$$
where:
$$
B(u,T) = \frac{1 - e^{-a(T- u)}}{a}
$$
As a result, under Hull-White, Black's formula gives a closed-form price to the option above:
$$
Caplet(t) = N(1 + \delta K) \left[ P(t, T + \delta) \Phi(d_+) - X P(t, T) \Phi(d_-) \right]
$$
where:
- $d\pm=\frac{\log\left( \frac{P(t,T+\delta)}{X P(t,T)} \right)}{\Sigma} \pm \frac{\Sigma}{2}$
- $\Sigma^2 = B(T, T+\delta)^2 \int_t^T e^{-2a(T - u)} \sigma^2(u) du $
- $\Phi$ is the cumulative distribution function of the standard gaussian $\mathcal{N}(0, 1)$
Hull-White calibration on cap volatilities
The first step is to strip caps vol to get caplet vols. See for example: http://www.smileofthales.com/financial/cap-floor-pricing-stripping-the-basics/
Let's suppose you want to calibration on caplets with expiries $T_1 < T_2 < \dots < T_n$. Usually, the model's volatility term structure is assumed piecewise-constant, with the same pillars: $T_1, \dots, T_n$.
You start with the option with the nearest expiry $T_1$, then determine the volatility $\sigma(T_1)$ that enables you to match the $T_1$ caplets price.
Then, you move on to $T_2$, the caplet price is a function of $\sigma(T_1)$ that is already known and $\sigma(T_2)$, so you determine the value of $\sigma(T_2)$ enabling you to match the $T_2$ and so on, until you get to $T_n$, and you are done.