$\newcommand{\De}{\Delta}$ This is not really a probability problem, since the equality \begin{equation}\label{1}\tag{1} l_t:=|\{s\in[0,t]\colon\De L_s\in B\}|=\sum_{i=1}^{N_t}1_B(Y_i)=:r_t \end{equation} holds almost everywhere on $\Omega$, for "almost" any joint distribution of the involved random variables -- provided only that $0\notin B$ and for all real $t\ge0$ \begin{equation*} N_t=\sum_{i=1}^\infty 1(\tau_i\le t), \tag{1.5} \end{equation*} where $0=\tau_0<\tau_1<\cdots$, so that for all natural $i$ and all real $t\ge0$ \begin{equation}\label{2}\tag{2} i\le N_t\iff\tau_i\le t. \end{equation} (Of course, here $\tau_1<\tau_2<\cdots$ are the times of the jumps of the Poisson process $N_\cdot$.)
Indeed, then for any $j\in\{0,1,\dots\}$ and any real $t\ge0$ \begin{equation*} L_t=\sum_{i=1}^{N_t}Y_i=\sum_{i=1}^j Y_i\quad\text{if}\quad \tau_j\le t<\tau_{j+1}. \end{equation*} Hence, for each real $s\ge0$, we have $\De L_s=Y_j$ if $s=\tau_j$ for some $j\in\{1,2,\dots\}$, and $\De L_s=0$ if $s\ne\tau_j$ for any $j\in\{1,2,\dots\}$. It follows that \begin{equation*} l_t=\sum_{j=1}^\infty 1(Y_j\in B,\tau_j\le t). \end{equation*}
On the other hand, for all real $t\ge0$ \begin{equation*} r_t=\sum_{i=1}^{N_t}1_B(Y_i) =\sum_{i=1}^\infty 1(Y_i\in B,i\le N_t)=\sum_{i=1}^\infty 1(Y_i\in B,\tau_i\le t), \end{equation*} by (\ref{2}).
Thus, $l_t=r_t$ for all real $t\ge0$, so that (\ref{1}) does hold.