How can I disable inline attachment previews (i.e. view as icon by default) in Mac Mail in macOS Mojave?
Applications (including Terminal) do not get "full disk access" (e.g. your user files) any more in Mojave.
Try to grant Terminal access in...System Preferences > Security & Privacy > Privacy > Full Disk Access
Unlock the system preference panel, by clicking the lock at the bottom left and filling in your password. Then either drag and drop Terminal.app onto the window, or navigate to it by clicking the plus sign (+).
Then launch Terminal and try your command again.
defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
PS. Alternatively you could disable SIP (System Integrity Protection) from Recovery, run your command, check that it worked and subsequently enable SIP again. Less elegant, usually not advised (in case you forget to re-enable it again), a lot of booting in and out, but just as effective.