defaults -currentHost write -globalDomain NSStatusItemSpacing -int xdefaults -currentHost write -globalDomain NSStatusItemSelectionPadding -int y
Logout/relogin to apply changes.
A value of 6 (x) for spacing and 12 (y) for padding looks good, but if you want more compact spacing, 4 (x) and 8 (y) may be better particularly on the 13 and 14 inch notched MacBooks. It seems that results are optimal when the padding value is twice the spacing value.
Values can be decreased down to 0 for extra-compact appearance. Keep in mind that below a certain value, the small Location Services symbol periodically appearing in the Control Center menu bar item might be cut off.
Revert back to default settings:
defaults -currentHost delete -globalDomain NSStatusItemSelectionPaddingdefaults -currentHost delete -globalDomain NSStatusItemSpacing
You can apply the settings without logging out with this:
ps -A | grep Core | awk '{ print $1 }' | xargs -I{} kill -9 {}
But logging out is more thorough, because otherwise you'll have to manually restart all of the third party apps that have menu bar icons.