You can get such information from Wikidata (as mentioned by @sn3fru) with the Wikidata Query Service at https://query.wikidata.org and a formulation of a SPARQL query.
Here is a SPARQL query for number of citizens recorded with given name grouped wrt. country:
SELECT ?name ?nameLabel ?country ?countryLabel ?count
WITH {
SELECT ?name ?country (count(?person) AS ?count) WHERE {
?person wdt:P735 ?name . # First names
?person wdt:P27 ?country .
}
GROUP BY ?name ?country
ORDER BY DESC(?count)
LIMIT 100
} AS %results
WHERE {
INCLUDE %results
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)
It shows that "John" is the most popular in the US (and globally) and Jean is the most popular given/first name in France.
An example with a query for most popular surnames in Denmark is:
SELECT ?name ?nameLabel ?count
WITH {
SELECT ?name (count(?person) AS ?count) WHERE {
?person wdt:P734 ?name .
?person wdt:P27 wd:Q35 .
}
GROUP BY ?name
ORDER BY DESC(?count)
LIMIT 100
} AS %results
WHERE {
INCLUDE %results
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?count)
In this case Hansen, Nielsen and Jensen show up on the top, see http://tinyurl.com/ybpgrk9v