Let $$q,p$$ denote the position and momentum. Consider a transform generated by $$g$$:

$$q' = q + \epsilon \{q,g\}---(1a)$$

$$p' = p + \epsilon \{p,g\}---(1b)$$

Then:

$$\{q',p'\} = \{q,p\}+o(\epsilon^2)+\epsilon \{\{q,g\},p\}+\epsilon \{q,\{p,g\}\}$$

The last two terms vanish since:

$$\{p,\{g,p\}\}+\{q,\{p,g\}\} = -\{g,\{q,p\}\}$$

And $$\{g,\{q,p\}\} = \{g,1\} = 0$$

Therefore this transform generated by $$g$$ is indeed a canonical transform.

In the equation above we use the fact that $$\{q,p\}=1$$. However, this does not hold in general if $$p,q$$ denotes some other variable with non-constant commutator. In those cases, the commutator is not preserved!:

$$\{q',p'\} \ne \{q,p\}---(2)$$

But we already know that (1a) and (1,b) are canonical transform, which should mean that every commutator should be preserved, even if $$q,p$$ are not position and momentum, which contradict (2)!

What is going on here?? Is it a problem caused by the higher-order term $$o(\epsilon^2)$$?

$$f~~\mapsto ~~f^{\prime} ~=~e^{-\varepsilon \{g,\cdot\}}f ~=~ f- \varepsilon \{g,f\} + \frac{\varepsilon^2}{2} \{g,\{g,f\}\} +o(\varepsilon^3),\tag{A}$$ where $$f=f(q,p,t)$$ and $$g=g(q,p,t)$$ are functions. One may use the Jacobi identity to prove that the finite transformation (A) respects the Poisson bracket: $$e^{-\varepsilon \{g,\cdot\}}\{f_1,f_2\}~=~\{e^{-\varepsilon \{g,\cdot\}}f_1,e^{-\varepsilon \{g,\cdot\}}f_2\} .\tag{B}$$ Returning to OP's question: If a Poisson bracket $$\{f_1,f_2\}$$ is not a constant, it might transform.