A counterexample to $(A\to B)\to\forall_xA\to\forall_xB$

In what follows, let $A,B$ denote formulas, let $x$ occur free in $A,B$, and let $y$ denote some variable that does not occur in $A,B$.

To prove that $(A \rightarrow B) \rightarrow (\forall x. A) \rightarrow (\forall x. B)$ is not derivable, it suffices to exhibit a first-order language $\mathcal{L}$, $\mathcal{L}$-formulae $A,B$, and an $\mathcal{L}$-structure $\mathcal{M}$ so that $\mathcal{M} \not\models (A \rightarrow B) \rightarrow (\forall x. A) \rightarrow (\forall x. B)$. This follows from completeness: if $(A \rightarrow B) \rightarrow (\forall x. A) \rightarrow (\forall x. B)$ was derivable, it would be validated by every model.

Of course, a structure $\mathcal{M}$ satisfies $\mathcal{M} \models (A \rightarrow B) \rightarrow (\forall x. A) \rightarrow (\forall x. B)$ precisely if it satisfies $$\mathcal{M} \models \forall y. ((A[x := y] \rightarrow B[x := y]) \rightarrow (\forall x. A) \rightarrow (\forall x. B))$$where $P[x := y]$ denotes the renaming of $x$ to $y$ in a formula $P$ which does not contain $y$.

For a sentence $P$, $\mathcal{M} \not\models P$ precisely if $\mathcal{M} \models \neg P$. So exhibiting a structure $\mathcal{M}$ for which $$\mathcal{M} \models \exists y. ((A[x := y] \rightarrow B[x := y]) \wedge (\forall x. A) \wedge \neg(\forall x. B))$$ holds will suffice as a counterexample.

Let $\mathcal{L}$ denote the usual language of arithmetic. Let $\mathcal{M}$ denote the set of natural numbers. Let $A$ denote $x = x$, let $B$ denote $x + x = x$. Then setting $y=0$, we obtain that the implication $0 = 0 \rightarrow 0 + 0 = 0$ holds, as does $\forall x. x = x$, but not $\forall x. x + x = x$.

edit: As I mentioned in the comments, a counterexample in the sense you mean in your edit ("$x$ occurs free in $A,B$, the formula $A \rightarrow B$ is true and the formula $\forall_xA \rightarrow \forall_xB$ is wrong") does not exist. There is no structure $M$ in which $A→B$ holds but $(∀x.A)→(∀x.B)$ fails. But this has no implications whatsoever with respect to the (non-)derivability of $(A \rightarrow B) \rightarrow (\forall x. A) \rightarrow (\forall x. B)$.