In ConversationEntry entity, MessageStatusCode will be populated if the messages are undelivered. So, query the ConversationEntry entity with MessageStatusCode to track failed or undelivered Messages in Salesforce Messaging.
SOQLs:
SELECT Id, ActorId, ActorName, ActorType, ConversationId, EntryType, Message, MessageStatus, MessageStatusCode
FROM ConversationEntry
WHERE CreatedDate = TODAY AND MessageStatusCode != null
SELECT ChannelName, MessagingEndUser.MessagingPlatformKey, StartTime, EndTime, MessagingEndUser.MessagingConsentStatus, MessagingEndUser.IsFullyOptedIn FROM MessagingSession WHERE Id IN (
SELECT ConversationId
FROM ConversationEntry
WHERE CreatedDate = TODAY)
MessageStatusCode is only populated when a message is undelivered.
Use the following article to find the reason for failure with the Error Code.
https://help.salesforce.com/s/articleView?id=sf.messaging_error_codes.htm&type=5