The Hamming distance between two binary numbers has an obvious analogue for numbers encoded using a base $\gt 2$. A different analogue is the following.
Let $\sigma \in S_n$ be a permutation which operates on the set $\{1,2 \dots,n\}$. then define: $$ \phi(\sigma) = \sum_{j=1}^n |\sigma(j)-j| $$ Q1. What is the usual name and symbol employed to refer to this function?
Q2. What is the value of $$H(n)=\sum_{\sigma \in S_n} \phi(\sigma)$$
Note: $H(1)=0, H(2)=2, H(3)=16$
I can't say much at all about Q1 (see the comment under OP). Q2 can be settled by changing the order of summation.
We know that to any pair of integers $i,j\in\{1,2,\ldots,n\}$ there are exactly $(n-1)!$ permutations $\sigma\in S_n$ such that $\sigma(j)=i$. Therefore we can calculate the sum as follows. $$ \begin{aligned} H(n)&=\sum_{\sigma\in S_n}\sum_{j=1}^n|\sigma(j)-j|\\ &=\sum_{j=1}^n\sum_{\sigma\in S_n}|\sigma(j)-j|\\ &=\sum_{j=1}^n\sum_{i=1}^n\left((n-1)!|i-j|\right)\\ &=(n-1)!\sum_{j=1}^n\sum_{i=1}^n|i-j|\\ &=(n-1)!\sum_{j=1}^n\left(\sum_{i=1}^j(j-i)+\sum_{i=j+1}^n(i-j)\right)\\ &=(n-1)!\sum_{j=1}^n\left(\frac{j(j-1)}2+\frac{(n-j)(n-j+1)}2\right)\\ &=(n-1)!\sum_{j=1}^nj(j-1)\\ &=(n-1)!\left(\frac{n(n-1)(n+1)}3\right).\\ \end{aligned} $$
The first step was just the change of summation order. In the second step I utilized the observation about the number of permutations with the property $\sigma(j)=i$.
In the next to last step I made the observation that the two parts yield identical sums but in reverse order. The last step can be done in many ways. Either by using the known formulas for $\sum_j j$ and $\sum_j j^2$, or by identifying the summands as $2{j\choose 2}$, placing them along a diagonal in Pascal's triangle, and using the Pascal triangle rule.
As a further reality check we see that the formula agrees with your calculations in the cases $n=1,2,3$.