$R$ has a nonzero polynomial that induces the zero function if and only if there are ideals $I$, $J$ such that $I$ is nontrivial, $IJ=0$, and $R/J$ is a ring satisfying the following condition:

There exists $n$ such that, for any $n$ elements $x_1, \dots x_n \in R/J$, the discriminant $\prod_{i<j} (x_i-x_j)=0$.

So $R$ is glued together out of an arbitrary ring and a ring that satisfies a specific polynomial identity.

Proof of only if: Let $I$ be the ideal generated by the coefficients of the nonzero polynomial and let $J$ be the ideal of zero divisors of $I$. We will show that for all $n$ elements $x_1,\dots x_n \in R$, $I\prod_{i<j} (x_i-x_j)=0$, so that $R/J$ satisfies this identity. To see this, take any $n$ elements $x_1,\dots,x_n\in R$ and take the Vandermonde matrix. Multiplying this by the vector of coefficients of the nonzero polynomial gives $0$. So multiplying on the other side by the adjugate matrix we still get $0$, but a matrix times its adjugate is just the identity times the determinant, so the determinant time each coefficient of the polynomial is $0$. The determinant of the Vandermonde matrix is just the discriminant $\prod_{i<j} (x_i-x_j)$.

Proof of if: Let $a$ be a nonzero element of $I$, let $n$ be the smallest $n$ such that $a\prod_{i<j} (x_i-x_j)=0$ for all $x_1,\dots,x_n \in R$, so that we have some $y_1,\dots y_{n-1}\in R$ that satisfy $a\prod_{i<j} (y_i-y_j)\neq0$ . Then all $x$ satisfy:

$$a\prod_{i<j} (y_i-y_j) \prod_{i=1}^{n-1} (x-y_i)=0$$

and the leading coefficient of that polynomial is nonzero.

Since $R/I$ is arbitrary, I think we should study rings satisfying $\prod_{i<j} (x_i-x_j)=0$. Such rings have all residue fields bounded in size by $n$, so all prime ideals are maximal and their spectra are totally disconnected topological spaces. Since the geometry of this kind of space is not very easy to classify, we might want to restrict our attention to the local rings:

If $R$ is a local ring with maximal ideal $m$, there is some $n$ such that, for all $x_1,\dots x_n \in R$, $\prod_{i<j} (x_i-x_j)=0$ if and only if $R/m$ finite and there is some $N$ such that every element $x\in m$ satisfies $x^N=0$.

Proof of only if: If $R/m$ is infinite, take $x_1,\dots x_n$ to be lifts of distinct elements in $R/m$. Set $N=\frac{n^3-n}{6}$. For all $x \in m$ we can take $x_i= x^i$ for $1\leq i \leq n$. Then

$$0=\prod_{i<j} (x_i-x_j) = \prod_{i<j} x^i (1-x^{j-i})$$

which is $x^{\frac{n^3-n}{6}}$, times a unit, so $x^N=0$.

Proof of if: If $a_1,\dots,a_m$ are lifts of all the elements of the residue field, $\prod_{i=1}^m (x-a_i)^N$ is monic and vanishes for all $x$, so the bottom row of the Vandermonde matrix of any $x_1,\dots, x_{mN}$ is a weighted sum of the previous rows, and so the determinant of the Vandermonde vanishes.

I don't think one can improve the classification much beyond this. Consider the examples $\mathbb Z[a,b]/(a^2,ab,2a)$, which is just slightly off from a nice infinite integral domain, but every element satisfies the identity $a x(x-1)=0$, and $\mathbb F_2[a_1,a_2,\dots]/(a_1^2,a_2^2,\dots)$, which is an extension of Manny Reyes's example where every element satisfies the identity $x^2(x-1)^2=0$. But I would be excited to see any further insights.

indecomposablering (i.e., no idempotents except $0$, $1$) such that $\hat{p}=0$ for some $p\neq 0$? – Frieder Ladisch Mar 21 at 13:47