If you want to, Mastodon lets you block DMs from people you don't follow:
1. Log in on your Mastodon server's website
2. Click "๐ Notifications" (on mobile it's just a ๐ icon at the bottom of the screen)
3. Click "show settings" double arrow icon in top right corner
4. Set "Unsolicited private mentions" to "Ignore"
Bear in mind that no one will know you've done this, so some people mention they've done this on their profile to avoid any confusion (but this is optional).