The event was emblematic of an about-face by Google. Over the last eight years, the company was closely associated with former President Barack Obama. Google employees overwhelmingly supported Mr. Obama’s presidential campaigns, and some later took roles in his administration. Eric Schmidt, the chairman of Alphabet, Google’s parent company, advised the Obama White House. And last year, Google employees gave $1.3 million to Hillary Clinton’s campaign to succeed Mr. Obama, compared with $26,000 to the Trump campaign, according to federal filings.

Now, the tech giant is scrambling to forge ties with Mr. Trump’s new administration and to strengthen its relationship with a Republican-dominated Congress. Most important, Google is trying to change the perception that it is a Democratic stronghold.

That has led to events like the party at the Smithsonian, which the institution said had cost at least $50,000. Mr. Schmidt has embarked on an East Coast charm offensive of Republican political leaders, including twice visiting Mr. Trump and his advisers at Trump Tower. Last month, Google also posted an opening to fill a position for a “conservative outreach” employee in its Washington office.

“Google has a target on its back because it is fundamentally viewed as a Democratic company,” said Gigi Sohn, a former senior adviser to Tom Wheeler, who was chairman of the Federal Communications Commission. “Even though it has reached out to Republicans, it can’t shake the image.”

Google said it had long had Republican lobbyists and had not changed its strategy.

“We’ve worked with both Republicans and Democrats for over a decade, advocating policies to encourage economic growth, innovation and entrepreneurialism,” the company said in a statement. “We’ll continue to do exactly that.”