This is actually a very loaded question. For instance, can it actually be moonshine if it is legal? Many would say that it can’t be.
This is largely because the term moonshine, in and of itself, was associated with high-proof distilled spirits, that were produced illegally, without government authorization. What made a whiskey moonshine was that it was simply distributed illegally.
Now, moonshine is generally associated with a white whiskey, one that came to the U.S. with Scot-Irish immigrants, who made a clear, unaged whiskey, that, in English, was called the water of life. This alcohol was legal before prohibition, or could be legal (there were still liquor laws).
This sort of whiskey did not take on the name moonshine though until later on, and that was only as a slang term, which specifically associated it with being unauthorized by the government; by very definition of the slang term, moonshine was illegal. If it was legal, then it wasn’t moonshine by definition.
So the question becomes, if you legalize moonshine, is it moonshine? Some are adamant that it is no longer moonshine. However, the type of spirit that is associated with moonshine, generally a clear unaged whiskey (you can also have rum, or other high-proof distilled spirits as well) can be produced legally. So its the same liquor that is associated with moonshine, but whether one can call it moonshine is debated.
To sum up, moonshine, by the definition of the term, at least historically, has to be illegal. Moonshine is just a high-proof distilled spirit that is distributed illegally. This spirit can be different forms, but often is an unaged, clear, whiskey. The spirit itself has been made legally both before and after prohibition. Today though, there is a push to sell this spirit as a specific alcohol called moonshine, which changes the definition of the term.