The term "Madrid" functions grammatically as a proper noun. A proper noun is a name used for an individual person, place, or organization, spelled with an initial capital letter. In this context, it specifically identifies the capital city of Spain, distinguishing it from all other cities and serving as a unique identifier.
While its primary part of speech is a noun, "Madrid" can also function as a proper adjective (or an attributive noun). In this role, it modifies another noun to indicate a quality, origin, or association with the city. For example, in the phrases "the Madrid government" or "a Madrid derby," the word modifies "government" and "derby," respectively. This adjectival use provides specific context to the noun it precedes without requiring a possessive form like "Madrid's."
For the purpose of an article, determining which grammatical function to use is a key stylistic choice. Using "Madrid" as a noun centers the city as the subject or object of a sentence ("Madrid is a vibrant city"). Using it as an adjective allows for more concise and descriptive phrasing by directly qualifying related concepts ("The Madrid art scene is world-renowned"). Recognizing this dual grammatical role is essential for achieving clarity and precision in the text.