Suppose I'm given a finite set of disjoint open sets (in the $p$-adic topology) $U_1,\ldots, U_n\subset\mathbb{Q}_p$, and another such $V_1,\ldots, V_n\subset\mathbb{Q}_p$.
Does there exist a polynomial function $f\colon \mathbb{Q}_p\to\mathbb{Q}_p$ such that $f(U_i)\subset V_i$ for each $i$?
No. For instance, if the closures of $U_1$ and $U_2$ intersect, then the closures of $f(U_1)$ and $f(U_2)$ must also intersect for any continuous $f$, so no such $f$ can exist if $V_1$ and $V_2$ have disjoint closures. Or suppose $U_1$ is unbounded but $V_1$ is bounded. Any nonconstant polynomial $f(x)$ goes to $\infty$ as $x$ goes to $\infty$ (since it is dominated by its leading term), so $f(U_1)\subseteq V_1$ implies $f$ must be constant, which then gives a contradiction if the $V_i$ have empty intersection.
On the other hand, it is true if you additionally require the $U_i$ to be compact. In that case, you can cover each $U_i$ by finitely many disjoint balls to assume that each $U_i$ is actually a ball. Multiplying by an appropriate power of $p$, we may assume $U_i\subset\mathbb{Z}_p$ for all $i$.
It now suffices to show that for any ball $B\subset\mathbb{Z}_p$, we can approximate the characteristic function $1_B:\mathbb{Z}_p\to\mathbb{Q}_p$ by a polynomial. That is, it suffices to show that for any $n$, we can find a polynomial $g\in\mathbb{Q}_p[x]$ such that $|g(x)-1|\leq p^{-n}$ for all $x\in B$ and $|g(x)|\leq p^{-n}$ for all $x\in\mathbb{Z}_p\setminus B$. If we can do this, then we can find the desired $f$ as a linear combination of such $g$, taking $B$ to be each of the $U_i$ and $n$ to be sufficiently large.
Now suppose $B$ has center $a$ and radius $p^{-i}$. Consider the polynomial $h(x)=\prod_b (x-b)$, where $b$ ranges over all residues mod $p^i$ except for the residue of $a$. Let $d=\sum_{k=1}^{p^i-1}v_p(k)$, so $d$ is the $p$-adic valuation of $h(x)$ for any $x\in B$. Note that if $x\in\mathbb{Z}_p\setminus B$, then $v_p(h(x))>d$, since $v_p(h(x))$ is computed by the same sum as $d$ except that one of the terms has been replaced by something greater than or equal to $i$ (coming from the factor $x-b$ where $b$ is the residue of $x$).
Now let $H(x)=p^{-nd}h(x)^n$. If $x\in B$, then $v_p(H(x))=0$, and if $x\in\mathbb{Z}_p\setminus B$, then $v_p(H(x))\geq n(d+1)-nd=n$.
Finally, let $g(x)=H(x)^{p^n-p^{n-1}}$. We again have $v_p(g(x))\geq n$ for all $x\in\mathbb{Z}_p\setminus B$. For $x\in B$, $H(x)$ is a unit mod $p^n$, so $g(x)$ is $1$ mod $p^n$ since $p^n-p^{n-1}$ is the order of the group of units mod $p^n$. That is, $|g(x)|\leq p^{-n}$ for $x\in\mathbb{Z}_p\setminus B$ and $|g(x)-1|\leq p^{-n}$ for $x\in B$, as desired.