The spell doesn't really seem to care who chooses or how it's chosen.
If the caster was meant to choose (a specific entity) it would be worded to say something like:
You choose (or name) a demigod, the spirit of a long-dead sage, or some other mysterious entity to mentally contact.
Or
You mentally contact a demigod, the spirit of a long-dead sage, or some other mysterious entity from another plane, of your choosing.
If it was meant to be random it would be worded something like:
You mentally contact a random demigod, the spirit of a long-dead sage, or some other mysterious entity.
If it was meant to be up to the DM... Well you get the point.
As it is written I don't see that there's meant to be any one exact option so whether the players choose or the DM does, I'd say go with whatever makes the game more interesting and fun. Given that it's a 5th-level spell that can be cast as a ritual with a casting time of one minute (or eleven minutes) and only has the verbal component it's costing the party nothing but time (and maybe a spell slot) either way.
Yes, you can learn a demon's name this way.
Dominate monster could be used to compel a demon to reveal its true name, but the demon gets a saving throw (and most demons have Magic Resistance, so they will have advantage on the saving throw). Since revealing its true name is "obviously harmful" to the demon, suggestion would not be able to compel it in that way.
The most common use for a demon's true name is as part of the 4th-level summon greater demon spell (in Xanathar's Guide to Everything):
At the end of each of the demon’s turns, it makes a Charisma saving throw. The demon has disadvantage on this saving throw if you say its true name. On a failed save, the demon continues to obey you.
Gate can also be used to summon a specific demon whose true name is known — perhaps one too powerful to be summoned and controlled via summon greater demon:
When you cast this spell, you can speak the name
of a specific creature (a pseudonym, title, or nickname doesn’t work). If that creature is on a plane other than the one you are on, the portal opens in the named creature’s immediate vicinity and draws the creature through it to the nearest unoccupied space on your side of the portal. You gain no special power over the creature, and it is free to act as the DM deems appropriate. It might leave, attack you, or help you.
Note that in the case of gate, knowing the demon's true name doesn't help you control it; likewise other spells like planar binding or, indeed, dominate monster are not more effective if the demon's true name is known.
This answer has been edited to include new information from Xanathar's Guide to Everything, which includes spells that specifically benefit from knowing a demon's true name.
Best Answer
Yes, but not easily, and it depends on your DM and your amassing the necessary preparatory knowledge
Based on the answer to this question it seems your DM could decide to allow you to contact a particular named entity with the contact other plane spell.
But since the spell description says nothing about forcing or guaranteeing a truthful answer, your best chance is to get the answer from another entity who knows a demon’s name and can be relied upon to tell it to you truthfully.
Toward this end, your DM might make you pass History, Arcana and/or Religion checks to know the name of a long-dead sage who (1) has a likelihood of possessing the requisite knowledge (of a demon’s true name) and (2) who is likely to be compliant and truthful to the questioning enabled by your casting contact other plane (perhaps based on their alignment and their connection to you via the plot or backstory of your adventure, e.g. were they a member of your faction 100 years ago and would sympathize with your purpose?).
Spending time on research at a relevant library might convince your DM to lower the DC for such checks.