Inside the courtroom (and in some settings outside the courtroom) an attorney-general or solicitor-general is recognized with this rank in the record and is so addressed by the justices of the Supreme Court, and I would assume lower courts as well.
From SCOTUS Oral Arguments in CITIZENS UNITED v. FEDERAL ELECTION COMMISSION (2009) (before Justice Kagan joined the Supreme Court):
APPEARANCES:
...
GEN. ELENA KAGAN, ESQ., Solicitor General, Department of Justice, Washington, D.C.; on behalf of the Appellee.
...
GENERAL KAGAN: Mr. Chief Justice and may it please the Court: ...
Justice Scalia and, afterward, Chief Justice Roberts, addressing the Solicitor General:
JUSTICE SCALIA: General Kagan, most -- most corporations are
indistinguishable from the individual who owns them, the local
hairdresser...
...
CHIEF JUSTICE ROBERTS: Thank you, General.
In oral arguments for HAWAII v. OFFICE OF HAWAIIAN AFFAIRS (2009):
APPEARANCES:
GEN. MARK J. BENNETT, ESQ., Attorney General, Honolulu, Haw.; on behalf of the Petitioners.
...
JUSTICE GINSBURG: But, General
Bennett, if I understand correctly ...
If you listen to SCOTUS oral arguments, you will hear that this use of General is the convention and not an exception. In the few oral SCOTUS arguments, I have listened to I have always heard an Attorney- or Solicitor-General addressed as General (with or without their last name) and never as Mr. or Ms.
"The folks at Pfizer are very appreciate and excited to hear from the
General." J. B. Kelly, a Dickstein partner, writing to a Missouri
official about an appearance by the attorney general at an event
sponsored by Pfizer. Eric Lipton; "Lobbyists, Bearing Gifts, Pursue Attorneys General", N.Y.T., Oct. 28, 2014
The post-modifying -General, in this case, is not military rank, but it is indeed rank. It is defined in the OED as
Having superior rank and comprehensive command or control.
In designations of civil, ecclesiastical, legal, and military
office-holders.
adjutant-, attorney-, captain-, controller-, governor-, inquisitor-, lieutenant-, receiver-, solicitor-, vicar-general, etc.:
It dates at least to the year 1393 (vicar general). This is not the same meaning as the general in general counsel, which is general in the sense of not specific
general counsel n. Law (chiefly North American) (a) a lawyer or
law firm retained by a client to represent the client generally,
rather than for a specific transaction or litigation (b) the
principal lawyer of a legal department, usually in a corporation or
government body. [First citation 1840] OED