A simple procedure is provided to write the equations of motion of mechanical systems with constraints as Hamiltonian equations with respect to a ¿Poisson¿ bracket on the constrained state space, which does not necessarily satisfy the Jacobi identity. It is shown that the Jacobi identity is satisfied if and only if the constraints are holonomic.
van der Schaft, A., & Maschke, B. M. (1994). On the Hamiltonian formulation of nonholonomic mechanical systems. Reports on mathematical physics, 34(2), 225-233. https://doi.org/10.1016/0034-4877(94)90038-8