It's a contraction of tref (town) and newydd (new). I believe the present of Y causes the T to mutate to D.
Here, it literally means "the".
Though in English, the place is called simply "Newtown" and not "the new town" or "the Newtown".
Is there any rule which one can apply to determine which town-names take the article 'Y[r]', or must one simply learn them individually?
Not really. Most don't have the article, so just learn the ones that do as you come across them.
This is the first time I have come across Y pronounced in Cymraeg as 'er' instead of 'ee' or 'uh' And why is 'drene' used for the word town, instead of . tre tref (trefi) trefol ?
A little bit confusing?
In answer to your first question: The usual rule is y in a final syllable is the "i"/"ee" sound and in a non-final syllable it's the "uh" sound.
The most common exceptions which all have "uh" despite being in final syllables are:
yn "in" (and other meanings)
Shouldn't be too difficult to remember.
And in answer to your second: The placename Y Drenewydd is made up of y "the" + dre "town" + newydd "new". The usual word for "town" as you say is tre(f), which is a feminine singular noun. When a feminine singular noun follows the word y then there's a soft mutation, hence y dre "the town".