There is a guy named Stephen Wigmore who has done a great deal of work on this, building on
an essay by Michael Martinez.
You can find Wigmore’s essays and estimates at this link. I’ve independently done some work on this material, and I think the numbers from Martinez and Wigmore are in the ballpark. (“In the ballpark”: an appropriate Americanism, since the World Series ended this week: Go Sox!).
He figures the total number of
Elves in
Beleriand before their reduction by
Morgoth’s assaults at about 1.25 million, along with perhaps 150,000
Edain (at their maximum population) and about 345,000
Dwarves.
Wigmore estimates 400,000 surviving Elves -
Noldor,
Sindar, and Avari - from Beleriand in
Lindon at the end of the
First Age. About five-eighths of them left for Eldamar or Tol Eressëa after the
War of Wrath, leaving a population of about 150,000 as the
Second Age began. He estimates the Elves remaining in Lindon at 30-40 thousand at the end of
the Third Age.
All the surviving Elves, Dwarves, and
Men of Beleriand at the end of the First Age must initially be in Lindon. The Dwarves mostly left for
Khazad-dûm, though some few continued to work
the old mines of Belegost. (That’s probably where
Thorin Oakenshield was living when
Gandalf visited him just before
Bilbo’s unexpected journey.) Nogrod seems to have been completely ruined. Wigmore thinks there were 30,000 surviving Edain, most of whom immigrated to
Númenor, leaving the remaining inhabitants of Lindon predominantly
Elvish.
He assumes
Rivendell at the end of the Third Age with a population well under one thousand (400 is his estimate, which seems a little low to me).
He guesses
Lórien and
Thranduil’s kingdom at the same time with populations of about 30,000 apiece.
His mean estimate for
Gondor is about 1.2 million as the
War of the Ring begins, with
Rohan about one-third that number.