How to calculate the Fourier transform of a mean filter in Matlab?
The 2D FIR 3x3 filter kernel you have provided is not finding the mean but the sum of samples. So you have to divide by 4 to get the mean. Furthermore it does not sum adjacent samples but diagonal ones.

Then if you create a 3x3 matrix h = [0,1,0 ; 1,0,1; 0,1,0] in matlab and you wish to perform a 2D-DFT on that matix h, then the following function call H = fft2(h) will return you the 3x3 discrete Fourier transform $H[k_1,k_2]$ (k1 rows, k2 columns) samples of the filter $h[n_1,n_2]$ as:

$$ H[k_1,k_2] = e^{ -j \frac{2\pi}{3} k_1} + e^{ -j \frac{2\pi}{3} k_2} + e^{ -j \frac{2\pi}{3} 2 k_1}e^{ -j \frac{2\pi}{3} k_2} + e^{ -j \frac{2\pi}{3} k_1}e^{ -j \frac{2\pi}{3} 2 k_2} $$ for $k_1,k_2 = 0,1,2$.

If you want to compute a larger $N \times N$ 2D-DFT on $h[n_1,n_2]$, then the following call H = fft2(h,N,N) will return you an $N \times N$ result as:
$$ H[k_1,k_2] = e^{ -j \frac{2\pi}{N} k_1} + e^{ -j \frac{2\pi}{N} k_2} + e^{ -j \frac{2\pi}{N} 2 k_1}e^{ -j \frac{2\pi}{N} k_2} + e^{ -j \frac{2\pi}{N} k_1}e^{ -j \frac{2\pi}{N} 2 k_2} $$ for $k_1,k_2 = 0,1,...,N-1$.