Yes, but if in English you wanted to say you were a citizen of London, you would say “I am a Londoner.” If you wanted to say you were a British or German citizen, you could say “I am an Englishman,” or, “I am a German,” but you probably wouldn’t, prefering “I am German,” instead.
I am not aware of a specific rule differentiating between cities and nations in this way, but I do know that words like “Londoner” and “New Yorker” are perfectly acceptable with an article.
It’s not a city/country thing, it’s a noun/adjective thing. No article is used prior to an adjective, but an article is used prior to a noun. “English” is an adjective, so you say “I am English” (with no article); “Londoner” and “Englishman” are nouns, so you say “I am a Londoner” and “I am an Englishman” (in each case with the article “a”).
By the same token, when “Danish” is used to represent someone from Denmark, it is an adjective, so you say “I am Danish” (no article), and when the noun “Dane” is used to represent someone from Denmark, you say “I am a Dane” (with the article “a”). Of course, “danish” can also be a noun, but only when it represents a pastry, so if you say “I am a danish” you are saying that you are a type of breakfast pastry.
I don’t speak German, so I don’t know for sure that the adjective “Berliner” refers to someone from Berlin while the noun “Berliner” refers strictly to a type of doughnut, but assuming that German is similar enough to English in that respect then the use of “ein” by Kennedy turned “Berliner” into a noun and thus turned Kennedy into a jelly doughnut.