I see two options:
First, you can mark ViewModelB with a marker and use this instead of your actual class name.
Messenger.Default.Send<string, IMessageTarget>("Something Happened");
This is not my favorite solution, but it should work.
Or you can register for messages with a specific token in ViewModelB when sending an ambiguous message from ViewModelA:
In ViewModelA:
Messenger.Default.Send<string>("Something Happened", "MessageDisambiguator");
In ViewModelB:
Messenger.Default.Register<string>(
this,
"MessageDisambiguator",
(action) => DoWork(action)
);
Significantly cleaner and still allows you to mock ViewModelB for testing purposes.
, , ...