The answer is negative. Here is a counterexample. For natural $j$, let
$$k_j:=\lfloor2^j/j\rfloor$$
and
$$r_j:=k_j/2^j.$$ Then $\frac1j-\frac1{2^j}<r_j\le\frac1j$ and hence $r_j$ is decreasing in $j\ge5$. Let $$\Delta_j:=(r_{j},r_{j-1}].$$ Here $j\ge6$ is a natural number.
Note that the intervals $\Delta_j$ are pairwise disjoint.
Let then
$$s_{j,\ell}:=r_{j}+\ell/2^{j+1}$$
for $\ell=0,\dots,\ell_j:=(r_{j-1}-r_{j})2^{j+1}$, so that $\ell_j$ is even, and
$$\delta_{j,\ell}:=(s_{j,\ell},s_{j,\ell+1}].$$
Note that
$\Delta_j$ is the disjoint union of the $\delta_{j,\ell}$'s over $\ell=0,\dots,\ell_j-1$.
Let, finally,
\begin{equation}
B:=\bigcup_{j=6}^\infty\bigcup_{q=0}^{\ell_j/2-1}\delta_{j,2q}.
\end{equation}
Take now any large enough natural $n$. Let \begin{equation} H_{n,i}:=\Big(\frac i{2^n},\frac{i+1}{2^n}\Big] \end{equation} for $i=0,\dots,2^n-1$.
From now on, suppose that $j\in\{n,\dots,2n\}$.
Note also that $|\delta_{j,\ell}|=1/2^{j+1}<1/2^n=|H_{n,i}|$, given the condition $j\in\{n,\dots,2n\}$, where $|\cdot|$ denotes the Lebesgue measure.
For any given $i=0,\dots,2^n-1$ such that $H_{n,i}\subseteq\Delta_j$, we have
$$B\cap H_{n,i}=\bigcup_{q=q_1}^{q_2}\delta_{j,2q}
\quad\text{and}\quad
H_{n,i}=\bigcup_{\ell=2q_1}^{2q_2+1}\delta_{j,\ell}$$
for some integers $q_1=q_{1;n,i}$ and $q_2=q_{2;n,i}$ such that $0\le q_1\le q_2\le\ell_j/2-1$.
Hence,
$|B\cap H_{n,i}|=\frac12|H_{n,i}|=\frac12\frac1{2^n}$.
So,
\begin{equation}
\frac{|B\cap H_{n,i}|}{2^{-n}}\Big(1-\frac{|B\cap H_{n,i}|}{2^{-n}}\Big)
=\frac14
\end{equation}
-- for each $j\in\{n,\dots,2n\}$ and each $i=0,\dots,2^n-1$ such that $H_{n,i}\subseteq\Delta_j$.
Note here that the length $|\Delta_j|$ of the dyadic interval $\Delta_j$ is $\asymp\frac1{j^2}$, and so, for a given natural $n$, the dyadic interval $\Delta_j$ contains at least
$c \frac{2^n}{j^2}$
dyadic intervals $H_{n,i}$, for some universal real constant $c>0$.
So, for $a_n$ as defined in the question, we have
\begin{equation}
a_n\ge\frac1{2^n}\sum_{j=n}^{2n}\ \sum_{i\colon H_{n,i}\subseteq\Delta_j}
\frac{|B\cap H_{n,i}|}{2^{-n}}\Big(1-\frac{|B\cap H_{n,i}|}{2^{-n}}\Big)
\ge
\frac1{2^n}\sum_{j=n}^{2n}c\frac{2^n}{j^2}\frac14\asymp\frac1n,
\end{equation}
which yields $\sum_n a_n=\infty$.
Starting with $k_j:=\lfloor2^j\epsilon_j\rfloor$ instead of $k_j:=\lfloor2^j/j\rfloor$, where $(\epsilon_j)$ is any sequence of positive numbers converging to $0$ slowly and regularly enough, we can similarly conclude that $a_n$ can go to $0$ however slowly.