The polynomial of the major index majW (v) over the subset T of the Coxeter group W is called the Mahonian polynomial over T, where majW(v) is a Mahonian statistic of an element v is an element of T, whereas the polynomial of the major index majW(v) with the sign (-1)W pound (v) over the subset T is referred to as the signed Mahonian polynomial over T, where W pound (v) is the length of v is an element of T. Gessel, Wachs, and Chow established formulas for the Mahonian polynomials over the sets of derangements in the symmetric group Sn and the hyperoctahedral group Bn. By extending Wachs' approach and employing a refinement of Stanley's shuffle theorem established in our recent paper (Ji and Zhang, 2024), we derive a formula for the Mahonian polynomials over the set of derangements in the even-signed permutation group Dn. This completes a picture which is now known for all the classical Weyl groups. Gessel-Simion, Adin-Gessel-Roichman, and Biagioli previously established formulas for the signed Mahonian polynomials over the classical Weyl groups. Building upon their formulas, we derive some new formulas for the signed Mahonian polynomials over the set of derangements in classical Weyl groups. As applications of the formulas for the (signed) Mahonian polynomials over the sets of derangements in the classical Weyl groups, we obtain enumerative formulas of the number of derangements in classical Weyl groups with even lengths. (c) 2024 Elsevier Ltd. All rights are reserved, including those for text and data mining, AI training, and similar technologies.