I don't know about Maryland, but when I was younger (about 25 years ago) the state of Tennessee sent a rep out to inspect our outhouse. I found out then that the Federal Government has regulations for outhouses..
We passed, he asked us to get some lime.
Be Content. And work for more time, not money. Money is inconsequential.
"Is it legal" is one of those fractal questions that can be very hard to answer. Does the state of Maryland have a law against it? A water quality regulation that regulates it? How about the county, or your municipality? Or is here a property association that has an enforceable opinion? A rural water district that operates wells that tap an aquifer recharged by your land? And that's even before we get to the Federal questions. I wouldn't expect a relevant federal statute, but in the many many volumes of the code of federal regulations, who knows? Watershed protection or surface water quality special zones are everywhere, under state and federal law or all the way down to municipal level; they sometimes prohibit stuff that is totally OK just on the other side of a contour line through your backyard that you can't even see. And then we get to the "what effect does the presence of the outhouse have on my ability to insure or finance or refinance or sell" and... there's more, but you get the idea. The only answer you can hope to get is that Permies bugaboo, "it depends" or "it's complicated".
I am not trying to make this harder than it needs to be, I just want to illustrate why there likely isn't a simple yes/no answer you can get here at Permies. Maybe you can get some "I had one on the western edge of Bosephus County and never had legal problems" anecdotes, but even then you won't know if maybe just the relevant authorities never noticed. Nothing short of several hours of research by a sharp local lawyer who has a good topographical map with your property marked on it who also knows his land use and environmental and health/safety stuff pretty well, is going to give you a firm answer.
To add to the above, start at the township level ....then move to county. If both clear it, it is probably OK. But, as has been pointed out there are many other potential problems. For example, there may be “neighborhood” restrictions that few people know about ..... except the person wanting to give you a headache.
Good decisions come from experience. Experience comes from making bad decisions. Mark Twain
COMAR Chapter 26.04.02. Sewage Disposal and Certain Water Systems for Homes and Other Establishments in the Counties of Maryland Where a Public Sewage Systems is Not Available is where you will find the State Regs, specifically Sec. 26.04.02.03.On-Site Sewage Disposal Permits that spells out the hoops the State of MD requires including;
An applicant shall submit an application for an on-site sewage disposal permit in a form required by the Approving Authority and shall include a site plan, which identifies soil evaluations, percolation and other test locations, proposed system design, existing and proposed improvements, proposed BAT or other treatment methods and the location of existing and proposed wells to serve the property, along with any relevant datum concerning wells or disposal systems within 100 feet of the property line, and any additional information the Approving Authority may request