dnd 5e – Is there any precedent for doubling the proficiency bonus only if the character has a given skill proficiency?

No official character options do this exactly

There are no official character options that do exactly what you’re proposing, but there are some character options which look similar if you squint – generally, they grant expertise if a character is already proficient but only in certain conditions.

The ranger’s Natural Explorer feature upgrades proficiency to expertise when the ranger makes Intelligence or Wisdom checks about their favoured terrain:

When you make an Intelligence or Wisdom check related to your favored terrain, your proficiency bonus is doubled if you are using a skill that you’re proficient in.

A draconic bloodline sorcerer’s Dragon Ancestor feature upgrades proficiency to expertise on charisma checks when dealing with dragons:

Additionally, whenever you make a Charisma check when interacting with dragons, your proficiency bonus is doubled if it applies to the check.

The artificer’s Tool Expertise feature upgrades proficiency to expertise for any tool the artificer is proficient with – so not strictly affecting skills, but it’s the closest to the second mechanic you proposed, in that it grants expertise on a proficiency if and only if the character already has it:

Starting at 6th level, your proficiency bonus is doubled for any ability check you make that uses your proficiency with a tool.

There does exist a class feature which is designed in such a way as to avoid the problem you have identified, though. The Purple Dragon Knight fighter’s Royal Envoy feature grants persuasion proficiency and expertise but in a more forgiving way than most features, allowing the choice of a different proficiency if the character is already proficient in persuasion:

At 7th level, you gain proficiency in the Persuasion skill. If you are already proficient in it, you gain proficiency in one of the following skills of your choice: Animal Handling, Insight, Intimidation, or Performance.

Your proficiency bonus is doubled for any ability check you make that uses Persuasion. You receive this benefit regardless of the skill proficiency you gain from this feature.

Expertise in persuasion is an important feature for the Purple Dragon Knight so that is always granted, but unlike most features of this kind it takes care that the basic proficiency it would grant is not wasted if the character was already proficient.

Aside: I personally prefer to just rule that, much like character creation allows overlapping skill proficiencies to be reassigned as free choice, if a class feature would grant you proficiency in a skill you already have, you can instead freely choose a new skill proficiency. Then there’s no proficiency disparity between a character optimally built at a higher level and one who levelled there naturally. (But to be clear this is in no way RAW; those class features all state that you gain a proficiency only if you don’t already have it, and the rule about free-choosing proficiencies when they overlap only applies to backgrounds/character creation.)