You would need to set up a webhook that forwards the SMS to an application, and that application can respond with an appropriate error message. Examples on how to process a request can be found at https://developer.nexmo.com/messaging/sms/code-snippets/receiving-an-sms
You can do this in two ways. One is to edit the number directly and set an "Inbound Webhook URL". Log into your dashboard, go to "Numbers", and then click the pencil/edit icon next to the number you are sending from. You can then fill in the URL that is listening for SMS messages under "SMS".
The second option is to set a fallback URL for all SMS messages. This is done by going to your account Settings page, and then filling in the "Inbound messages" box under "Default SMS settings". This URL will then forward any SMS to the webhook URL on any number that does not have a bespoke webhook assigned.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…