The Hahn-Banach theorem for a locally convex space X says that for any disjoint pair of convex sets A, B with A closed and B compact, there is a linear functional $l\in X^*$ separating A and B. So, it would be nice to have a counterexample where both A and B are closed, but not compact. As no-one has posted such an example, I'll do that now, where the space X is a separable Hilbert space. In fact, as with fedjas example, there will be no separating linear functionals at all, not even noncontinuous ones.
Take μ to be the Lebesgue measure on the unit interval [0,1] and X = L2(μ). Then let,
- A be the set of f ∈ L2(μ) with f ≥ 1 almost everywhere.
- B be the one dimensional subspace of f ∈ L2(μ) of the form f(x) = λx for real λ.
These can't be separated by a linear function $l\colon X\to\mathbb{R}$. A similar argument to fedja's can be used here, although it necessarily makes use of the topology. Suppose that $l(f)\ge l(g)$ for all f in A and g in B. Then $l$ is nonnegative on the set A-B of f ∈ L2 satisfying $f(x)\ge 1-\lambda x$ for some λ. For any $f\in L^2$ and for each $n\in\mathbb{N}$, choose $\lambda_n$ large enough that $\int(1-\lambda_nx+\vert f\vert)_+\,d\mu\le \Vert(1-\lambda_nx+\vert f\vert)_+\Vert_2\le 4^{-n}$ and set $g=\sum_n 2^n(1-\lambda_n x+\vert f\vert)_+\in L^2$. This satisfies $\pm f+2^{-n}g\ge1-\lambda_nx$, so $\pm l(f)+2^{-n}l(g)\ge 0$ and, therefore, $l$ vanishes everywhere.
If you prefer, you can create a similar example in $\ell^2$ by letting $A=\{x\in\ell^2\colon x_n\ge n^{-1}\}$ and B be the one dimensional subspace of $x\in\ell^2$ with $x_n=\lambda n^{-2}$ for real λ.
Note: A and B here are necessarily both unbounded sets, otherwise one would be weakly compact and the Hahn-Banach theorem would apply.

