How does a Lagrangian with delta potential transform to a Hamiltonian? Suppose the Lagrangian was given as:
$$L = \frac{1}{2}\int_{-\infty}^{\infty} \underbrace{\left(\dot{A(}z)^2-A(z)^2\right)+\left(\dot{Q(}z)^2\delta(z)-Q(z)^2\delta(z)\right)+2\dot{Q(}z)\cdot A(z) \delta(z)}_{= \mathcal{L}} \,\,\,dz\tag{1}$$
where Q is localized at $0$. The above are basically two harmonic oscillators that are coupled to each other in the last term. Now, if I wanted to Legendre-transform this in order to get the Hamiltonian, I wouldn't know what to do with the Dirac-delta function. 
The conjugate momentum for A(z) is fairly straight forward:
$$P_A = \frac{\partial \mathcal{L}}{\partial \dot{A\,}(z)} = \dot{A\,}(z)\tag{2}$$
but how should I deal with the other conjugate momentum $P_Q$? Would it be 
$$P_Q = \frac{\partial \mathcal{L}}{\partial \dot{Q\,}(z)} = \dot{Q\,}(z)\delta(z)+A(z)\delta(z)\tag{3}$$
or 
$$P_Q = \frac{\partial \mathcal{L}}{\partial (\dot{Q\,}(z)\delta(z))} = \dot{Q\,}(z)+A(z).\tag{4}$$
I run into problems using the former, but the latter does not seem correct.
 A: *

*Lagrangian formulation. The trick is to appreciate that OP's Lagrangian 
$$ L ~=~ \frac{1}{2}\int_{\mathbb{R}} \! dz ( \dot{A}(z)^2 -A(z)^2) 
~+~ \frac{1}{2}( \dot{Q}(0)^2 -Q(0)^2)~+~ \dot{Q}(0) A(0) \tag{A}$$
is a combination of a bulk theory in the $A$-sector and a boundary theory in the $Q$-sector (say, living on a brane located at $z=0$). 

*Euler-Lagrange (EL) equations. The bulk EL eq. is 
$$ \ddot{A}(z)+A(z)~\approx~+\delta(z)\dot{Q}(0), \tag{B}$$ 
while the boundary EL eq. is 
$$ \ddot{Q}(0)+Q(0)~\approx~-\dot{A}(0). \tag{C}$$
If we assume that the bulk field $A(z)$ is continuous without $\delta(z)$-contributions, then eq. (B) implies that $\dot{Q}(0)\approx 0$. Eq. (C) then implies that $\ddot{A}(0)\approx 0$. Eq. (B) then implies that $A(0)\approx 0$. Eq. (C) then implies that $Q(0)\approx 0$. In conclusion: The two harmonic oscillators $A$ and $Q$ decouple, and the amplitudes vanish at $z=0$.

*Momenta. The bulk momentum is
$$ P_A(z)~=~\frac{\delta L}{\delta \dot{A}(z)}~=~\dot{A}(z), \tag{D}$$
while the boundary momentum is
$$ P_Q(0)~=~\frac{\partial L}{\partial \dot{Q}(0)}~=~ \dot{Q}(0)+A(0).\tag{E} $$

*Hamiltonian formulation. The Hamiltonian gains a bulk and a boundary part 
$$\begin{align} H ~&=~ \int_{\mathbb{R}} \! dz ~ P_{A}(z)\dot{A}(z)~+~P_Q(0)\dot{Q}(0)~-~L\cr~&=~\frac{1}{2}\int_{\mathbb{R}} \! dz ( P_{A}(z)^2 +A(z)^2) 
~+~ \frac{1}{2}( (P_Q(0)-A(0))^2 +Q(0)^2). \end{align}\tag{F}$$
