Yes, but it would be extraordinarily expensive, and probably a millionaire’s mansion.
For the record, there is - was - a “real” Hogwarts School of Witchcraft and Wizardry - or, rather, Beauxbatons. In 2017, the Mimbulus Mimbletonia Association was reported to be opening a wizarding school for Muggles at Château de Jolibert in Bourgougnague, France.
From one source:
The school will offer classes over four days, from May 25 to May 28, 2017. Only 100 lucky students can attend. Students must be 16 or older, and students under 18 will need a permission slip from their parents.
The four-day experience is modeled after the first Harry Potter book, Harry Potter and the Sorcerer’s Stone. Students will take part in a sorting ceremony, learn to play Quidditch, and take classes in Botany, Potions and Charms.
There is a catch. The Mimbulus Mimbletonia Association is the brainchild of two French Harry Potter fans, so all lessons and activities will be conducted in French. Only fluent French speakers will be able to participate. Better start brushing up on your high school French now!
However, the school is only a “summer camp” put on by renting a pre-existing castle, with only 100 tickets listed for sale, due to limited capacity within said castle.
I assume that you mean building a castle from scratch. For this, I’ll be turning to the example of Guédelon Castle, or “Château de Guédelon”, a medieval French castle being built near Treigny, France.
The castle is the focus of an experimental archaeology project aimed at recreating a 13th-century castle and its environment using period technique, dress, and material. Jacques Moulin, chief architect for the project, designed the castle according to the architectural model developed during the 12th and 13th centuries by Philip II of France.
Construction started in 1997 under Michel Guyot, owner of Château de Saint-Fargeau, a castle in Saint-Fargeau 13 kilometres away. However, Château de Guédelon is still under construction, even in 2020, and is due to be completed in 2023.
That means that one is able to build a small castle in about 26 years…at least, without magic. However, a fantasy castle the size of Hogwarts Castle could take hundreds of years to build with medieval techniques, much like the cathedral construction projects of Europe.
The longer it takes to construct a building, usually, the more money it costs.
However, what about the cost of building a castle the size of Hogwarts?
According to one modern-day company that builds castles:
The cost of the castle varies anywhere from $400 to $600 dollars per square foot, and they do a lot of authentic work. We are not just talking about a late Middle Ages mansion here. The late Middle ages is when castles fell out of use, and the structures were built more as a residency for the wealthy. This happened because the traditional castle was not very effective anymore, because of gunpowder.
According to another source:
Built in the style of Windsor Castle, Hogwarts stretches over 414,000 square feet.
According to the private castle-building company, the cost of Hogwarts would come out to around $165,600,000 - 248,400,000. Or, in more readable cost, Hogwarts would cost around $165–248 million dollars to build today.
According to article “Here's How Much it Would Cost to Build Hogwarts in Real Life”:
BigRentz, an online marketplace for renting construction equipment, recently calculated the costs of building various fictional locations, such as Batman's Bat Cave, The Wall from Game of Thrones, and you guessed it—Hogwarts. And it turns out, magical castles are even more expensive than you might think.
According to the company's calculations, the castle itself would cost $169,740,000. Built in the style of Windsor Castle, Hogwarts stretches over 414,000 square feet. The Great Hall, which measures 5800 square feet, would alone cost a whopping $870,000.
Moving beyond the castle walls, the eight greenhouses would cost $175,000, and Hagrid's hut would come in at $400,000. Building the Quidditch pitch would cost another $1,031,980. And for the One-Eyed Witch Passage running between Hogwarts and Honeydukes? A full $2,490,000.
In total, BigRentz calculates that Hogwarts's construction bill would come to a whopping $174.5 million. And that's just construction costs. The cost of furnishing, supplying, and running the school—where tuition is free—would add significantly to that figure.
Thus, you could afford to build a Hogwarts if you were a millionaire - or billionaire - and wanted a particularly unique mansion.
Compared to other residences, Hogwarts’ price tag also wouldn’t even come close to some of the other, most expensive and valuable mansions and palaces in the world.
For example, according to article “World's Most Expensive Mansions”, Buckingham Palace is estimated to be worth around $1.55 billion, and the White House is estimated to be worth $410 million.
Witanhurst Mansion, located in London, was estimated to have been built for $450 million from 1913–1920, and was designed by architect George Hubbard for soap magnate Sir Arthur Crosfield on an 11-acre (4.5 ha) site.
It cost almost double the price to build Hogwarts.
Currently under renovation, Witanhurst will, when finished, become the second largest and second most valuable mansion in London, surpassed only by Buckingham Palace. Its interior space is expected to total some 90,000 square feet, bringing its value to an estimated $450 million.
Built in the early twentieth century by the heir to a soap fortune, the original house had 25 bedrooms. New owners have since added a second three-story villa and dug out some 40,000 square feet of basement, a space that The New Yorker recently said: “amounts to an underground village.”
Just who those new owners are has been something of a mystery. The New Yorker article, titled “House of Secrets: Who Owns London’s Most Expensive Mansion?” made the case that the owners were a publicity-shy Russian family who built its fortune in fertilizer.
It’s worth noting that, according to the article “Disneyland's $1 billion Star Wars: Galaxy's Edge attraction is opening this month—take a look inside”, Disney also spent more to build Galaxy’s Edge theme park land at Disneyland in California than building an entire Hogwarts would cost.
Galaxy's Edge covers 14 acres, and cost an estimated $1 billion, according to USA Today. Guests will be transported to Batuu, a planet that isn't depicted in Star Wars movies but is in the Star Wars book “Thrawn: Alliances,” a part of the so-called Star Wars Expanded Universe.
According to the article “10 questions about Wizarding World at Universal Studios Hollywood”, compare the costs to build the Wizarding World of Harry Potter theme park land at Universal Studios, Orlando, Florida, which built a Hogwarts Castle façade for the ride “Harry Potter and the Forbidden Journey”:
How much will it cost? The overall project, which will include facility and infrastructure upgrades at the adjacent television and movie studio, has been pegged at $500 million. The original Wizarding World, which opened in 2010 at Universal Studios Florida, reportedly cost $265 million.