Taken literally, $\hat H = -\frac{1}{2}\frac{d^2}{dx^2} + \lambda \delta(x)$ is not a genuine operator on $L^2(\mathbb R)$. One can see this by noting that even if you could make sense of the expression $\delta(x)\psi(x)$, the function
$$(\hat H\psi)(x) = -\frac{1}{2}\psi''(x) + \lambda \delta(x)\psi(x)$$
would not be square-integrable.
Consider instead the free particle on the Hilbert space $L^2\bigg((-\infty,0)\cup(0,\infty)\bigg)$, with inner product
$$\left<\psi,\phi\right> = \lim_{a,b\rightarrow 0^+}\left[\int_{-\infty}^{-a}\overline{\psi(x)}\phi(x) dx + \int_b^\infty \overline{\psi(x)}\phi(x) dx\right]$$
The form of the Hamiltonian will simply be $\hat H = -\frac{1}{2}\frac{d^2}{dx^2}$, but now we must be careful about domain issues. Watch what happens when we check for Hermiticity.
$$-2\langle \psi, \hat H \phi\rangle = \lim_{a,b\rightarrow 0^+}\left[\int_{-\infty}^{-a} \overline{\psi(x)}\phi''(x) dx + \int_b^\infty \overline{\psi(x)}
\phi''(x)dx\right]$$
$$=\lim_{a,b\rightarrow 0^+}\left[\overline{\psi(-a)}\phi'(-a)-\overline{\psi'(-a)}\phi(-a) - \overline{\psi(b)}\phi'(b) + \overline{\psi'(b)}\phi(b) \right] -2\left<\hat H\psi,\phi\right>$$
For the standard free particle on a line, that boundary term vanishes because if $\psi$ and $\phi$ are twice (weakly) differentiable, then they and their first derivatives must be at least continuous. On this Hilbert space however, it is possible for twice-differentiable functions to have completely different limits as $x\rightarrow 0$ from the left and right.
If $\hat H$ is to be Hermitian, then the domain consisting of twice-differentiable functions whose second derivatives are square-integrable (which is the standard domain in the $L^2(\mathbb R)$ case) is too big. We need to add restrictions in the form of boundary conditions to ensure that the boundary term vanishes.
You can check that the boundary conditions
$$\lim_{x\rightarrow 0^+}\psi(x) = \lim_{x\rightarrow 0^-}\psi(x) = \alpha$$
$$\lim_{x\rightarrow 0^+}\psi'(x) - \lim_{x\rightarrow 0^-}\psi(x) = \lambda\alpha$$
with $\alpha\in \mathbb C$ and $\lambda\in\mathbb R$ are sufficient to kill the unwanted boundary term. However, this is precisely the set of boundary conditions which arises from the $\delta(x)$ potential.
To recap, we see that the free particle on the disconnected line requires a specific type of boundary condition on the domain of the Hamiltonian at the point of disconnection in order for $\hat H$ to be Hermitian. There are multiple choices one could make (e.g. one could require that $\psi(x)\rightarrow 0$ as $x\rightarrow 0$), but if we demand that (i) $\psi$ approaches the same value from the left and right, and (ii) $\psi'$ have a jump discontinuity equal to a real number times the aforementioned limit, then $\hat H$ will be Hermitian.
On the other hand, we obtain the same conditions by considering the Hamiltonian $\hat H = -\frac{1}{2}\frac{d^2}{dx^2} + \lambda \delta(x)$ on the Hilbert space $L^2(\mathbb R)$, as long as we don't ask too many questions about $\hat H$ at the point $x=0$. We can therefore consider the somewhat loose delta function Hamiltonian to be a "recipe" which gives us the same result as the more rigorous - but also somewhat more annoying - free particle on a disconnected line.