The last time Bill de Blasio appeared on a popular prime-time network drama, it was as merely a name on a chalkboard, an afterthought in the set design of a 2000 episode of “The West Wing.”

What a difference a mayoralty makes.

In another sign of his rapidly growing national profile, Mayor de Blasio earned a few minutes of screen time on Sunday’s episode of “The Good Wife,” the CBS series about high-powered lawyers in Chicago.

Mr. de Blasio, playing an exaggerated version of himself, found a uniquely New York way to irritate one of the show’s characters: squawking at him from the back-seat television in a taxicab.

In a running gag, Nathan Lane, who plays the fastidious Clarke Hayden, is stuck in traffic on a business trip to New York and is forced to listen to an unyielding loop of Mr. de Blasio, accompanied by Gershwin-inflected music, talking up the tourism delights of the city.