There are no other ways to learn encode thoughts, and nothing short of a wish spell can allow you to cast encode thoughts without already knowing the cantrip.
The feats Spell Sniper and Magic Initiate, as well as the class features Pact of the Tome and Magical Secrets, all specify that the selected spell comes from a class’s list.
Pact of the Tome:
choose three cantrips from any class’s spell list
Choose two spells from any classes
Choose a class: bard, cleric, druid, sorcerer, warlock, or wizard. You learn two cantrips of your choice from that class's spell list.
You learn one cantrip that requires an attack roll. Choose the cantrip from the bard, cleric, druid, sorcerer, warlock, or wizard spell list.
Encode thoughts doesn’t appear on any class list.
Additional details: Encode thoughts cannot be stored in the magic item Spell Gem:
A spell gem can contain one spell from any class’s spell list.
An encode thoughts spell scroll would be unintelligible to everyone:
If the spell is on your class’s spell list, you can read the scroll and cast its spell without providing any material components. Otherwise, the scroll is unintelligible.
Other potential sources of cantrips that specify a class list: all other class features, aberrant dragon mark feat.
What about the Thief Rogue’s Use Magic Device and the Artificer’s Magic Item Savant with an encode thoughts spell scroll?
Both of these abilities say:
You ignore all class, race, and level requirements on the [use of magic items]
I argue that it still doesn’t work. These abilities let you ignore all class requirements. Trouble is, there are no class requirement to ignore. These two class features assume that there is some class based restriction we are ignoring that would normally be satisfied by having a particular class. Because there is no class that allows for casting encode thoughts, there is no proper class requirement to ignore with these class features.