Since $\cot x$ has simple poles at $m\pi$ for $m \in \mathbb{Z}$, we must take some precautions in case the interval $[a,b]$ contains such values. If such a value lies in the open interval $(a,b)$, we can choose to require that $p$ has a zero there, or we can choose to interpret the integral as a principal-value integral. Since $p$ is smooth (it need not be a polynomial, weaker assumptions suffice), the principal value exists. If only one of $a$ and $b$ is a multiple of $\pi$, we must require that $p$ has a zero there, if both of the endpoints are multiples of $\pi$, it suffices to require $p(a) = p(b)$ as well as $p'(a) = p'(b)$ and use the principal value. $\DeclareMathOperator{\Imp}{Im}$
Now start on the right hand side and consider a partial sum:
\begin{align}
\sum_{k = 0}^{N} \sin (2kx)
&= \Imp \sum_{k = 0}^{N} e^{2ikx} \\
&= \Imp \frac{e^{2i(N+1)x}-1}{e^{2ix}-1} \\
&= \Imp \frac{e^{(2N+1)ix} - e^{-ix}}{e^{ix} - e^{-ix}} \\
&= \Imp \frac{e^{(2N+1)ix} - e^{-ix}}{2i\sin x} \\
&= \frac{\operatorname{Re}\bigl(e^{-ix} - e^{(2N+1)ix}\bigr)}{2\sin x} \\
&= \frac{\cos x - \cos \bigl((2N+1)x\bigr)}{2\sin x}\,.
\end{align}
Thus
\begin{equation}
2\sum_{k = 1}^{N} \int_{a}^{b} p(x) \sin (2kx)\,dx
= \int_{a}^{b} p(x)\cot x\,dx - \int_{a}^{b} \frac{p(x)}{\sin x}\cos \bigl((2N+1)x\bigr)\,dx\,.
\end{equation}
It remains to see that the last integral tends to $0$ as $N \to \infty$.
If $[a,b]$ contains no zero of $\sin x$, or $p(m\pi) = 0$ for all $m\pi \in [a,b]$, this is an immediate consequence of the Riemann-Lebesgue lemma, since then $\frac{p(x)}{\sin x}$ has only removable singularities and can be considered a continuous (or more regular, if $p$ is regular enough) function on $[a,b]$.
More care is required if we work with the principal value of the integral, for then the derivative of $\frac{p(x)}{\sin x}$ has double poles at $m\pi$ and is not locally integrable there, whence the straightforward integration by parts doesn't work.
But considering a small $\varepsilon > 0$ and assuming $a < 0 < b$, for $0 < \lvert x\rvert < \varepsilon$ we can write
\begin{equation}
\frac{p(x)}{\sin x} = \frac{p(0)}{\sin x} + \frac{p(x) - p(0)}{\sin x}\,.
\end{equation}
The first term is odd, hence
\begin{equation}
\int_{-\varepsilon}^{\varepsilon} \frac{p(0)}{\sin x}\cos (\alpha x)\,dx = 0
\end{equation}
for all $\alpha$. The second term above is bounded and differentiable, hence straightforward integration by parts shows that
\begin{equation}
\Biggl\lvert \int_{-\varepsilon}^{\varepsilon} \frac{p(x) - p(0)}{\sin x}\cos (\alpha x)\,dx \Biggr\rvert \leqslant \frac{C}{\lvert \alpha\rvert}
\end{equation}
with a constant $C$ independent of $\alpha$. Doing that for all $m\pi \in (a,b)$, and in case $a = m_1\pi < m_2\pi = b$ using the analogous estimates for the integral over $[a,a+\varepsilon] \cup [b-\varepsilon,b]$ with $p'(a) = p'(b)$ shows that also in the principal-value case we have
\begin{equation}
\int_a^b \frac{p(x)}{\sin x}\cos\bigl((2N+1)x\bigr)\,dx = O(N^{-1})
\end{equation}
if $p$ satisfies the conditions mentioned above.