how to remove name from text message notifications but not the banner on lock screen

when the notification pops up on the lock screen it just says “message”
Remove the name from your contact list.
Go to Settings > Notifications > Messages and play around with the Show Preview settings.
Is this a message from someone in your contact list, of a 2FA code?

Original thread: https://forums.imore.com/threads/how-to-remove-name-from-text-message-notifications-but-not-the-banner-on-lock-screen.412932/