Is there any way to have a coded string such that it can be decoded in multiple ways? This is more out of curiosity than anything, having no knowledge of cryptography.

But say I have strings "test1" and "test2", is there any way/algorithm to encode the two strings to an encoded string "string" such that when "string" is decoded with "key1", it returns "test1", and likewise for "key2" and "test2"?

Thanks!
Maybe this example is only remotely related to the question, but anyway:

VeraCrypt application for encrypting computer's disks has an ability to offer part of the disk capacity to reach the plausible deniability with the help of 2 different passwords:


the first one unlocks so called outer volume with a non-important content,
the second one unlocks inner, hidden volume with the important content.


So both passwords are used in the same manner (in a command or a dialog box) and only by choosing between them decides which content will be accessible.