Derivative interaction: $\mathcal{H}_\mathrm{int}\neq - \mathcal{L}_\mathrm{int}$. Question about Feynman Rules
Some general remarks:
In the operator formalism, the non-covariant extra term in the Hamiltonian is cancelled by a non-covariant term coming from the naïve time ordering symbol: $$ \mathrm T\sim\mathrm T_\mathrm{cov}-e^2\phi^2A^2_0 $$
You can find the details in ref.1, section 6-1-4.
On the other hand, the case of the path-integral formalism is covered by item 2 below.
The formal equivalence $Z_1=Z_2$ can be proven for any Hamiltonian of the form $$ H\sim A^{ij}\pi_i\pi_j+B^i(\phi)\pi_i+C(\phi) $$ of which your Hamiltonian is an example of. For the proof and relevant discussion, see ref.2, Vol.1., section 9.3.
For the discussion of the path-integral quantisation of non-abelian gauge theories, see ref.2, Vol.2, chapters 15.4 -- 15.8. Ref.1, chapter 12-2 is also worth a read. In short, "$Z_1=Z_2$" up to the subtleties introduced by gauge-invariance.
References
[1] Itzykson & Zuber, Quantum field theory.
[2] Weinberg, Quantum theory of fields.
AccidentalFourierTransform has already given a good answer. Here we will provide more details & justifications for a class of non-gauge derivative interactions.
We start from a Lagrangian action, $$ S[Q]~=~\int\! dt~ L~=~S_0[Q]+S_{\rm int}[Q], \qquad L~=~ L_0(Q,\dot{Q})+L_{\rm int}(Q,\dot{Q}),$$ $$ S_0[Q]~=~\int\! dt~ L_0(Q,\dot{Q}), \qquad L_0(Q,\dot{Q})~=~\frac{1}{2}\dot{Q}^2~=~\frac{1}{2} \dot{Q}^i G_{ij} \dot{Q}^j,$$ $$ S_{\rm int}[Q]~=~\int\! dt~ L_{\rm int}(Q,\dot{Q}), \qquad L_{\rm int}(Q,\dot{Q})~=~A_i\dot{Q}^i - V, $$ $$ G_{ij}~=~G_{ij}(Q), \qquad A_i~=~A_i(Q), \qquad V~=~V(Q), \tag{1}$$ which is quadratic in velocities. We shall assume that the Lagrangian action (1) is manifestly Lorentz covariant. [We are using DeWitt condensed notation$^1$ to suppress spatial (but not temporal) dimensions, which may superficially obscure the manifest Lorentz covariance. So e.g. the $\frac{1}{2}\dot{Q}^2$ term in $L_0$ is implicitly accompanied by a $\frac{1}{2}(\nabla Q)^2$ term in $V$, and so forth.] The canonical momentum read $$ P_i~=~G_{ij}\dot{Q}^j+A_i.\tag{2}$$ We stress that the corresponding Hamiltonian action is also Lorentz covariant, $$ S_H[Q,P]~=~\int\! dt~ L_H~=~S_{H,0}[Q,P]+S_{H,{\rm int}}[Q,P], $$ $$ L_H~=~P_i \dot{Q}^i-H(Q,P), \qquad H(Q,P)~=~H_0(Q,P)+H_{\rm int}(Q,P), $$ $$ S_{H,0}[Q,P]~=~\int\! dt~ L_{H,0}, \qquad L_{H,0} ~=~P_i \dot{Q}^i-H_0(Q,P), \qquad H_0(Q,P)~=~\frac{1}{2}P^2~=~\frac{1}{2}P_i G^{ij}P_j,$$ $$S_{H,{\rm int}}[Q,P] ~=~-\int\! dt~H_{\rm int}(Q,P), \qquad H_{\rm int}(Q,P)~=~ -A^iP_i + \color{red}{\frac{1}{2} A^2}+V,\tag{3}$$ despite the non-covariant term $A^2:=A_iG^{ij}A_j$ marked in red in eq. (3).
We mention (for a later instructive comparison with eq. (6) below) that $$ L_{\rm int}(Q,\dot{Q})+H_{\rm int}(Q,P) ~\stackrel{(2)}{=}~ - \color{red}{\frac{1}{2} A^2(Q)},\tag{4}$$ although eq. (4) will not be used in what follows. Eq. (4) corresponds to OP's second formula.
So far we have only discussed the classical theory. In the corresponding quantum mechanical operator formulation, the operators $\hat{Q}^i$ and $\hat{P}_j$ are in the Heisenberg picture.
We next consider the interaction picture. Here velocity and momentum are related via $$\dot{q}^i~=~\frac{\partial H_0(q,p)}{\partial p_i}~=~G^{ij}p_j,\tag{5}$$ which should be compared with the corresponding relation (2) in the Heisenberg picture. Eq. (5) has two consequences.
Firstly, we derive the somewhat surprising relation $$ L_{\rm int}(q,\dot{q})+H_{\rm int}(q,p)~\stackrel{(5)}{=}~\color{red}{\frac{1}{2} A^2(q)},\tag{6}$$ which has the opposite sign of eq. (4)! This sign of eq. (6) will be important in what follows.
Secondly, eq. (5) implies the equal-time CCR $$ [\hat{q}^i(t),\dot{\hat{q}}^j(t)]~\stackrel{(5)}{=}~i\hbar~ G^{ij} {\bf 1}. \tag{7} $$ We derive that the covariant time-ordering is $$ T_{\rm cov} \{\dot{\hat{q}}^i(t_1)\dot{\hat{q}}^j(t_2)\}~\equiv~\frac{d}{dt_1}\frac{d}{dt_2} T \{\hat{q}^i(t_1)\hat{q}^j(t_2)\}~\stackrel{(7)}{=}~T \{\dot{\hat{q}}^i(t_1)\dot{\hat{q}}^j(t_2)\} +\color{red}{i\hbar~ G^{ij} {\bf 1} \delta(t_1\!-\!t_2)}. \tag{8}$$ We have marked the non-covariant term in red.
Consider next a Wilson line $$ \exp\left\{ \frac{i}{\hbar}\int\!dt~ A_i(q)\dot{q}^i \right\}. \tag{9}$$ From Wick's theorem, eq. (8) exponentiates to $$ T_{\rm cov} \exp\left\{ \frac{i}{\hbar}\int\!dt~ A_i(\hat{q})\dot{\hat{q}}^i \right\}~\stackrel{(8)}{=}~ T \exp\left\{ \frac{i}{\hbar}\int\!dt\left( A_i(\hat{q})\dot{\hat{q}}^i -\color{red}{\frac{1}{2} A^2(\hat{q})} \right)\right\} . \tag{10}$$
We are now ready to consider$^2$ the Hamiltonian phase space path integral/partition function $$Z_H~\sim~\int\! {\cal D}Q~{\cal D}P~ \exp\left\{ \frac{i}{\hbar} S_H[Q,P]\right\} $$ $$~\sim~\langle \Omega | T_{\rm cov} \exp\left\{ - \frac{i}{\hbar}\int\!dt~ H(\hat{Q},\hat{P})\right\}| \Omega \rangle$$ $$~=~\langle \Omega | T \exp\left\{ - \frac{i}{\hbar}\int\!dt~ H(\hat{Q},\hat{P})\right\}| \Omega \rangle$$ $$~\sim~\langle \omega | T_{\rm cov} \exp\left\{ - \frac{i}{\hbar}\int\!dt~ H_{\rm int}(\hat{q},\hat{p})\right\}| \omega \rangle$$ $$~=~\langle \omega | T \exp\left\{ - \frac{i}{\hbar}\int\!dt~ H_{\rm int}(\hat{q},\hat{p})\right\}| \omega \rangle$$ $$~\stackrel{(6)}{=}~\langle \omega | T \exp\left\{ \frac{i}{\hbar}\int\!dt\left( L_{\rm int}(\hat{q},\dot{\hat{q}})-\color{red}{\frac{1}{2} A^2(\hat{q})} \right)\right\}| \omega \rangle$$ $$~\stackrel{(10)}{=}~\langle \omega | T_{\rm cov} \exp\left\{ \frac{i}{\hbar}\int\!dt~ L_{\rm int}(\hat{q},\dot{\hat{q}})\right\}| \omega \rangle ,\tag{11}$$ where the $\sim$ symbol denotes equality up to a constant normalization factor. We find that two effects cancel, the non-covariant term in the interaction Hamiltonian (6) and the Wick's theorem (10), so that the partition function (11) is Lorentz covariant.
We mention for completeness an interaction picture phase space path integral $$Z_H~\stackrel{(11)}{\sim}~ \int\! {\cal D}q~{\cal D}p~ \exp\left\{ \frac{i}{\hbar} \left(S_{H,0}[q,p] +\int\!dt~ L_{\rm int}(\hat{q},\dot{\hat{q}}) \right)\right\} .\tag{12}$$
The naive Lagrangian path integral $$Z_L~\sim~\int\! {\cal D}Q \exp\left\{ \frac{i}{\hbar} S[Q]\right\} \tag{13}$$ may differ from the Hamiltonian phase space path integral (11) because it lacks the determinant from the Gaussian integration over momenta $P_j$. In practice, it is often implicitly implied that the path integral measure ${\cal D}Q$ in eq. (13) contains this determinant factor by definition. In other words, the definition of $Z_L$ is tweaked to agree with $Z_H$. See also this related Phys.SE post.
References:
M.D. Schwartz, QFT and the Standard Model, 2014; Section 9.2.
C. Itzykson & J.B. Zuber, QFT, 1985; Subsection 6-1-4.
S. Weinberg, Quantum Theory of Fields, Vol. 1, 1995; Sections 7.2, 7.5 & 9.3.
--
$^1$ Notation: We will suppress spatial (but not temperal) dimensions by using DeWitt condensed notation. Capital letters for fields in the Heisenberg picture and small letters for fields in the interaction picture. The metric $G_{ij}(Q)$ in configuration space should not be confused with the space(time) metric.
$^2$ It should be stressed that this derivation is formal & shamelessly focused on the non-covariant term marked in red. We have ignored various higher-order operator-ordering issues, cf. e.g. this & this Phys.SE posts.