I have seen powerful spells that require a material component that costs a fair number of gold pieces. If a character chooses one of these spells, do they know what the cost is?
The player has knowledge of the item's cost, because they have read it in the rules.
The character has knowledge of the item's cost, in the same way they know how much a sword is worth, or any other object for that matter.
Whether or not the actual value of the item in the game lists its gold cost is up to you, and if you rule it's a more obscure material, perhaps the character has no knowledge of it. We're playing characters that exist within their own world, and they possess much knowledge we don't about the world they live in.
This is often reflected by things such as Nature, Religion, or History checks - a way to gauge whether or not your character is aware of something. On the other hand, the material components required to cast a spell is part of the valuable information they need to cast a spell; they need to know that the crystal ball for scrying, for example, has a value of 1,000gp or the spell will fail.
A wizard casting a spell which (in the rules) states some component with a minimum GP requirement would certainly know whether or not a specific component will work for that spell. Whether we choose the in-game reason to be because "it has sufficient magical resonance" or some other "wizard did it" hand-waving, or because in-game the GP requirement is the actual requirement is up to the DM. At our table we don't use the gold piece cost as the in-game reason, to guard against the following scenario:
Wizard's player: I need to cast this spell which requires a 100GP diamond, but I only have a 50gp diamond. Hey Barbarian, take this diamond and sell it back to me for 100GP.
Wizard: Casts spell with now-100gp-diamond