Just want to know whether the government has a special lawyer or something like that.
It depends on the situation
In a criminal case
When the government is prosecuting a criminal case, they are represented by a prosecutor. For a federal case, that prosecutor would be a United States Attorney or Assistant United States Attorney (AUSA). For a state case, they'd be a District Attorney, Deputy District Attorney, or Assistant District Attorney.
In civil cases
Generally, the Federal government would be represented in civil cases by lawyers with no special title. In many cases, these would be lawyers working for the Civil Division of the Department of Justice, but other agencies also have lawyers to represent them in more specialized litigation—for example, the IRS Chief Counsel's Office.
Before the Supreme Court
When the Federal government is before the Supreme Court, they are represented by lawyers from the Office of the Solicitor General. That could be the Solicitor General themself, a Deputy Solicitor General, or an Assistant to the Solicitor General. In cases where the government is not a party, the office may be asked for its input on a case by the Supreme Court via a Call for the Views of the Solicitor General.
In US, what kind of lawyer represent the government in the court?
It depends on the type of matter and the government's role therein. There is no such thing as "lawyer specialized in governmental matters".
Only very few specializations can be mostly ruled out. For instance, the States never get married, whence expertise in divorce law is needed only when legislators are addressing an initiative toward enactment or amendment of statutory law.
In criminal court the prosecutor represents the government, and his role is to prove that the defendant's conduct meets all the elements that constitute a crime.
The legal matters the Food and Drug Administration handles are very different from those the Securities Exchange Commission and the USCIS address. The approach of delegating to governmental agencies the regulation and enforcement of specific types of issues translates to a need for lawyers versed in the corresponding branches of law.
Additionally, every government department is exposed to lawsuits pursuant to its employer capacity. Hence the need for expertise in labor law just like with any other employer.
These are only some examples illustrating the point why there is no narrow "kind of lawyer" for representing the government in court.
The U.S. has a unified legal profession (regulated primarily at the state level, but with limited federal regulation before federal courts and agencies). While different lawyers representing the government may have different job titles, they are all members of the same profession with the same kind of occupational licensing (unlike most developed countries).
This is in contrast to the barrister-solicitor distinction in the U.K., to the notary-advocate distinction in many civil law countries, and to the separate professions organized in the judicial branch of judges and prosecutors respectively in many civil law countries.
Typically, a U.S. lawyer is admitted to practice before the courts of a court of a U.S. state, district or territory, and that admission is used as a minimum job qualification of a lawyer in government service, in addition to other job specific qualifications such as prior relevant experience. Prior to being admitted to the practice of law in a particular state, every lawyer in that state takes the same bar exam (part of which is state specific and part of which is a pair of national multiple choice exams) and before that (with a couple of state specific exceptions, primarily for California and Maine) graduates from some U.S. law school (any accredited law school in the U.S. provides a sufficient pre-requisite to takin the bar exam. There are no specialized curricula for graduating from one law school versus another law school). Earning a bachelor's degree (typically with four years of full time study after high school), in turn, in a prerequisite for attending law school (which usually involves three years of full time study), although no particular undergraduate major is required to go to law school.
For example, even though I have never handled a criminal case in court more serious than a traffic ticket, I have the occupational license as a lawyer to be a prosecuting attorney or a criminal defense attorney, even in a death penalty case. The licensing requirement is the same.
Admission to the bar of a particular federal court such as the U.S. Supreme Court, is largely a formality, with the exception of the Foreign Intelligence Surveillance Act court which requires a security clearance.
Another narrow exception is that additional patent specific qualification is required for a U.S. lawyer to "prosecute patents" (i.e. to conduct patent practice interacting with the U.S. Patent and Trademark Office to obtain and establish the validity of patents), although patent infringement litigation in ordinary federal courts does not require a separate specialized qualification.
Exceptions For Judges
There are some narrow exceptions for judges.
Some state courts allow non-lawyers to serve on their lowest level courts in rural areas (e.g., Colorado has four non-lawyer judges who serve in limited jurisdiction county courts, out of a hundred or two total at that level). Often judges with the title "justice of the peace" is a non-lawyer, and sometimes a non-lawyer court clerk is given quasi-judicial authority over select matters (like uncontested probate cases, issuance of subpoenas, entry of default judgments, and enforcement of judgments).
In the federal courts, a judge nominated by the President and confirmed by the U.S. Senate may serve despite not being a lawyer, although that almost never happens (in modern times).
Sometimes administrative law judges in a narrow area like unemployment claims or zoning request cases are also not lawyers, although this is uncommon in an administrative board making decisions not subject to de novo review at a higher level that don't have a strong political component.
Exceptions For Specialist Non-Lawyer Professionals
There are also certain non-lawyer professionals who can operate independently in a role overlapping that of a lawyer in a specialized area of practice, most commonly, in patent practice (where registered patent professionals who have qualifications established by the U.S. Patent and Trademark Office which qualified them for U.S. PTO, but not in ordinary courts) and in federal tax practice (in which accountants in addition to certain tax law specialist professionals who are neither lawyers nor accountants may serve before the IRS and in Tax Court practice, but not in ordinary courts).
But this is done by government employees pretty much only in patent practice where patent examiners practice law while having a professional qualification other than being a lawyer created by the U.S. Patent and Trademark Office (this federal regulation of patent practice pre-empts state law prohibitions on the practice of law by non-lawyers).
In certain circumstances (usually in cases involving minor offenses or with the advice and guidance of a lawyer member of the judge-advocate corps), non-lawyers can also act as prosecutors or advocates in the court martial system of the U.S. military.