It is still not clear to me what exactly is being asked because the question mixes binary mods (=the remainder function) and quotient rings, and the range of the variable is unclear. Anyway, the point of this answer is to explain why certain things are impossible.
Fact. If $f(x)=\sum_{i=0}^n a_ix^i$ is a polynomial with integer coefficients, $p$ is a prime number, and $m\equiv n\pmod p$, then
$$f(m)\equiv f(n)\pmod p.$$
Proof. Raising to a power preserves a congruence, so we have $m^i\equiv n^i\pmod p$ for all $i$. Congruences also preserve integer linear combinations, and the claim follows.
Corollary. It is impossible to find a polynomial $f(x)\in\Bbb{Z}[x]$ such that for all choices of base-$p$ digits $n_i\in\{0,1,\ldots,p-1\}$, $0\le i<m$, we would have
$$
f(\sum_{i=0}^{m-1}n_ip^i)=n_{m-1}.
$$
Proof. The base-$p$ expansions the integers $x_1=p^{m-1}$ and $x_2=p^{m-1}-p$
have disting top digits: with $x_1$ we have $n_{m-1}=1$ but with $x_2<p^{m-1}$ the "leading digit" is equal to zero. Yet $x_1\equiv x_2\pmod p$, so the Fact implies that $f(x_1)\equiv f(x_2)\pmod p$. But $1\not\equiv0\pmod p$, so we have run into a contradiction.
As Greg Martin explained, it is also impossible to find a polynomial $f(x)\in\Bbb{Z}[x]$ such that for all natural numbers
$$
n=\sum_{i=0}^{m-1}n_ip^i, \quad n_i\in\{0,1,\ldots,p-1\},
$$
we would have $$f(n)=n_{m-1}p^{m-1}.\qquad(*)$$ Recapping the reason: $(*)$ implies that $0\le f(n)/n \le 1$ for all natural numbers. Hence $f(n)$ has linear growth, implying that $f(n_1)>f(n_2)$ whenever $n_1>n_2$, which is a contradiction.
On the other hand, if we fix a prime $p$, and a natural number $m$, then
it is possible to find a polynomial $f(x)\in\Bbb{Q}[x]$ such that for all
$n$ in the range $0\le n<p^m$ we have
$f(n)=n_{m-1}p^{m-1}$. Again $n=\sum_in_ip^i$ with $n_i\in\{0,\ldots,p-1\}$. This is a simple application of Lagrange interpolation.
For example with $p=m=2$ the polynomial
$$
f(x)=\frac13(-7x+9x^2-2x^3)
$$
has the prescribed values $f(0)=f(1)=0$, $f(2)=f(3)=2$. Here
- I don't know right away, if it might be possible to replace $f$ with another polynomial with integer coefficients.
- In the linked MO-thread the answer seems to produce a polynomial with rational $p$-adic integers as its coefficients. Basically it allows rational coefficients as longs as the numerators are not divisible by $p$.