If $$ L \to L' = L +\frac{dF(q,t)}{dt}$$ the corresponding Hamiltonian becomes
$$ H \to H' = H - \frac{\partial F(q,t)}{\partial t} $$ as shown here. Moreover, the canonical momentum becomes $$ p \to P = p + \frac{\partial F}{\partial q} $$ while $$ q \to Q = q $$ as shown here.
These formulas allow us to check the invariance of Hamilton's equations explicitly. Concretely,
\begin{align}
\frac{dq}{dt} &= \frac{\partial H}{\partial p} \notag \\
\end{align}
becomes
\begin{align}
\frac{dQ}{dt} &= \frac{\partial H'}{\partial P} \\
\therefore \quad \frac{dq}{dt} &= \frac{\partial \left(H - \frac{\partial F(q,t)}{\partial t} \right)}{\partial P} \\
\therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial P} - \frac{\partial }{\partial P} \left( \frac{\partial F(q,t)}{\partial t} \right) \\
\therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial P} \\
\therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial p} \frac{\partial P}{\partial p} \\
\therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial p} \quad \checkmark
\end{align}
where I used that $F$ does not depend on $P$ and $$\frac{\partial P}{\partial p} =\frac{\partial }{\partial p} \left( p+ \frac{\partial F}{\partial q} \right) = 1. $$
Analogously, we can check Hamilton's second equation:
$$ \frac{dp}{dt}= -\frac{\partial H(q,p,t)}{\partial q} .$$
However, there is a subtlety. After the transformation, we have on the right-hand side $\frac{\partial H'(Q,P,t)}{\partial Q}$. But here we need take into account that $p$ also depends on $q$, since $ p \to P = p + \frac{\partial F(Q,t)}{\partial Q} $. Therefore
\begin{align}
\frac{\partial H'(Q,P,t)}{\partial Q} &= \frac{\partial H'(Q,p + \frac{\partial F}{\partial q} ,t)}{\partial Q} \\
&= \frac{\partial H'(Q,p,t)}{\partial Q} + \frac{\partial H(Q,p,t) }{\partial p} \frac{\partial p}{\partial Q} \\
&= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{\partial^2 F(Q,t)}{\partial Q \partial t} + \frac{\partial H(Q,p,t) }{\partial p} \frac{\partial p}{\partial Q} \\
&= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{\partial^2 F(Q,t)}{\partial Q \partial t} + \dot Q \frac{\partial \left(P- \frac{\partial F}{\partial q}
\right)}{\partial Q} \\
&= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{\partial^2 F(Q,t)}{\partial Q \partial t} - \dot Q \frac{\partial
}{\partial Q} \frac{\partial F}{\partial q} \\
&= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{d}{dt} \frac{\partial F}{\partial Q} \,.
\end{align}
where we used that
$$ \frac{d}{dt} \frac{\partial F}{\partial Q}= \frac{\partial^2 F(Q,t)}{\partial Q \partial t} + \dot Q \frac{\partial
}{\partial Q} \frac{\partial F}{\partial q} . $$
Using this, we can rewrite Hamilton's second equation after the transformation as follows:
\begin{align}
\frac{dP}{dt}&= -\frac{\partial H'(Q,P,t)}{\partial Q} \\
\therefore \quad \frac{d}{dt} \left( p+ \frac{\partial F(q,t)}{\partial q} \right) &= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{d}{dt} \frac{\partial F}{\partial Q} \\
\therefore \quad \frac{dp}{dt} + \frac{d}{dt} \left(\frac{\partial F(q,t)}{\partial q} \right)&= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{d}{dt} \frac{\partial F}{\partial Q} \\
\therefore \quad \frac{dp}{dt} &= -\frac{\partial H}{\partial q} \quad \checkmark
\end{align}
EDIT: The subtlety was also noted here, but unfortunately without an answer and a few years ago there was even a paper which didn't notice it and claimed that Hamilton's equations are not invariant.