The code you cite appears on page 72 of the book. Right before it, on page 71 you read:
Compared with the Portmanteau test of Chapter 1, the degrees of freedom of
the chi-square distribution in Theorem 2.6 is adjusted by $pk^2$, which is the number of AR parameters in a VAR(p) model. In practice, some of the AR parameters in a VAR(p) model are ﬁxed to 0. In this case, the adjustment in the degrees of freedom of the chi-square distribution is set to the number of estimated AR parameters.
adj is the degrees-of-freedom adjustment (as you can read in the help file for the
mq function). In the example,
adj=18 because $18=2\times 3^2$ since the model has a trivariate response ($k=3$) and two autoregressive lags ($p=2$).