There exist known methods of surveilling people within their homes and elsewhere and even harassing them there that provide complete anonymity for the surveillor/harasser. If those means afford such a degree of insulation for the surveillor/harasser that no defendant can ever be identified or proven, can a harassee take the matter of those harassments to a civil court so as to seek a judgement of that surveillance/harassment being illegal and doing harm as a simple matter of law?
Laws are different around the world and you didn't bother to state your location, but typically no- this is not how the system works.
What would be the point? There's no defendant. You, the plaintiff would argue against thin air and then what? The court rules in your favour, declares this illegal, and nothing happens because there's no defendant.
Is it so you can use this ruling if you find out later? Pretty sneaky. Let's look into how this would actually work.
You bring up a case- Jackson vs a mannequin or something. You make your arguments. The defense makes literally no defense. The judge rules in your favour, with a result of nothing as there is no defendent.
Next, you find the culprit and bring a case against them. You point out that this is illegal because we came to that decision last week. What's that defendant? An argument against it being illegal? Too bad, the decision has been made.
When I posted this answer, it was before the "Nyah, I was ranting about government spying but was deliberately vague- aren't I clever?" comment and I assumed it was against, say, a neighbour but it doesn't really matter. You cannot have a system that makes a judgement without a defendant so it can be applied later.
In the United States federal courts, the answer is no. The U.S. Constitution limits their jurisdiction to "cases or controversies," which requires adverse parties. It also requires a plaintiff who has standing, which requires that the court's resolution of the case will provide some relief for that injury.
The case you're describing fails on both points. First, as you noted, there is no defendant adverse to the plaintiff. Second, there's no indication that the action you're talking about would change the amount of surveillance the plaintiff is being subjected to.
To see why this wouldn’t work, let’s take a slightly different example. Suppose you have something stolen from you, but you can’t identify the thief. Suppose also, in this jurisdiction, for whatever reason, there is some ambiguity about the legality of theft (perhaps due to the nature of the thing that was stolen). Even if it would be interesting, important, and useful to resolve the ambiguity:
If the ambiguity would be resolved in the direction that there was no law against the particular form of theft, then you would be out of luck regardless, and should go to the legislature first to petition for a revision of the laws.
If the ambiguity would be resolved in the direction that the theft was in fact illegal, there would be nothing for the court to do, since the court lacks both control over and access to the thief and the stolen property. You would be out of luck regardless, and should go to law enforcement or private investigators to catch the thief and locate the stolen property first.
Courts have such a big caseload of urgent problems generally that it is a more or less ironclad rule that you can’t bring hypothetical questions or questions where the court cannot actually remedy the injustice (for reasons of jurisdictional or physical impossibility). You have to have an actual live issue and make a showing that the court could actually provide redress of grievances. No one’s putting murder, rape, and domestic violence cases on pause for days so the court can spend a few days in the ivory tower musing on a purely academic (“moot”) question.
With regards to being surveilled/harassed: you would either have to catch the surveillor/harasser in the act (if it was illegal) or first change the law to ban these types of surveillance/harassment (if it was technically legal). If you don’t know who’s surveilling/harassing you, and the court doesn’t either, what do you expect the court to do? Even if they agree with your theory of the case, they can’t enforce anything against an unknown, much less a potentially unknowable, malefactor.
The Foreign Intelligence Surveillance Act, 50 USC 1803–1805 provides the legal framework for such surveillance by the federal government. The Attorney General can declare an emergency, apply for a warrant but not have to wait for the warrant to be issued. They apply to the FISA Court, which is a special court, and generally warrants are granted (nearly 20,000 granted, less than a dozen rejected). This is a secret court, so any information available probably will not be released, or will be heavily redacted. Congressional authority for secret courts stems from 50 USC 1803(c), where court rules can be set up to protect the security of records held by FISC. Here is one ruling (against petitioner, alleged to be Yahoo). The NY Times famously published a report indicating that the courts have secretly ruled, in classified rulings (ergo secret law), that the "special needs" doctrine has been expanded and that "collection and examination of Americans’ communications data to track possible terrorists does not run afoul of the Fourth Amendment". This pertains to a mass surveillance program carried out by the NSA.
Theoretically, you could sue various governmental agencies (FBI, CIA, NSA, TFI, MIB...) demanding under FOI that they provide records. You make a direct request to the agency; if you are not satisfied with the result, you file a lawsuit in federal court in your district. This paper may be helpful, assuming you are going pro se. You may also want to review this chapter, which pertains to declassifying information, since the agency response might be "that's classified". The bottom line is that if the information you seek has been deemed classified, then your only recourse is declassification review; if they deny having any record and you can provide no proof of such a record, your suit will be dismissed. Unlike FOI where you can ask for "any and all", you have to specify a document for declassification under MDR review.
Surveillance by other levels of government (state police, county sheriff, school district) is less likely to be immunized from review since they don't deal in national security issues. Surveillance by Facebook or your local grocery store or TV station could be revealed if you allege harm by one of these parties and sue them, in which case as part of discovery you could demand production of their surveillance of you. They may petition for summary dismissal, so your petition needs to be specific enough to survive their counter-motion.
You have to name a respondent. The standard solution is to name all possible respondents.