Yes, "City" is capitalized in "the City of San Francisco"—and the rule extends to similar municipal references. Here's why and when this applies.
When "City" (or "County," "Town," "Village," "Borough," "Municipality") forms part of an official governmental entity's formal name, it functions as a proper noun and takes capitalization:
Use lowercase when referring generently to the geographic place or the concept of a city:
AP Stylebook: Capitalize "City" as part of a formal title ("City of San Francisco"); lowercase in generic use ("the city of San Francisco" if not using formal title).
Chicago Manual of Style: Similar—capitalize when part of the formal name of the incorporated municipality.
Government Printing Office: Capitalizes in official designations.
Ask: "Is this the entity's legal, incorporated name?" If yes → capitalize. If no → lowercase. "The City of San Francisco" is the municipal corporation's legal name; "San Francisco city hall" is a building belonging to that entity.