The Rogue's Phantom subclass from Tasha's Cauldron of Everything has the following feature at 3rd level:
Whispers of the Dead
Whenever you finish a short or long rest, you can choose one skill or tool proficiency that you lack and gain it... You lose this proficiency when you use this feature to choose a different proficiency that you lack.
At 6th level, all Rogues get to choose two skills (or thieves' tools) for expertise:
...choose two of your skill proficiencies, or one of your skill proficiencies and your proficiency with thieves’ tools. Your proficiency bonus is doubled for any ability check you make that uses either of the chosen proficiencies.
Can you apply expertise to a skill gained from Whispers of the Dead, and what then happens if you choose to gain proficiency in a different skill after a rest?