Recall that for every $a$ in $\mathbb C$, $M_t=\mathrm e^{aB_t-a^2t/2}$ defines a martingale $(M_t)_{t\geqslant0}$ starting from $M_0=1$ and such that $\mathrm dM_t=aM_t\mathrm dB_t$. Hence, for every $T\geqslant0$, $ M_T=1+\int_0^TaM_t\,\mathrm dB_t. $ If $a=\mathrm i$, this yields $ \mathrm e^{\mathrm iB_T}=\mathrm e^{-T/2}+\mathrm e^{-T/2}\int_0^T(\mathrm i\mathrm e^{\mathrm iB_t})\,\mathrm e^{t/2}\,\mathrm dB_t. $ Keeping only the real part, one gets $ \cos B_T=\mathrm e^{-T/2}-\mathrm e^{-T/2}\int_0^T\sin(B_t)\,\mathrm e^{t/2}\,\mathrm dB_t=\mathbb E(\cos B_T)+\int_0^TH_t\,\mathrm dB_t, $ where $ H_t=-\sin(B_t)\,\mathrm e^{(t-T)/2}. $ Integrability is not an issue here since $\|H_t\|_\infty\leqslant1$ for every $t\leqslant T$.
Note: As regards your comment, writing $B_T=B_t+(B_T-B_t)$ yields the identity $ \mathbb E(\cos B_T\mid \mathcal F_t)=\mathbb E(\cos(B_T-B_t))\cos B_t=\mathrm e^{(t-T)/2}\cos B_t, $ which suggests to use the martingale $N_t=\mathrm e^{(t-T)/2}\cos B_t$. Then $ \cos B_T=N_T=N_0+\int_0^T\mathrm dN_t, $ Since $N_0=\mathrm e^{-T/2}$ and, by Itô's formula, $\mathrm dN_t=-\mathrm e^{(t-T)/2}\sin(B_t)\mathrm dB_t$, the identification of the solution $(H_t)_{0\leqslant t\leqslant T}$ follows directly. To sum up, $H_t$ solves the identity $ H_t\mathrm dB_t=\mathrm dM_t,\qquad M_t=\mathbb E(\xi\mid\mathcal F_t). $