Yes, however you need to have some number of stone walls as well. So about 10 or even 5 percent can be stone walls.
Also, make sure to go a long distance away from other villages before starting it. You can travel for multiple lives on horse, just bring a shovel and adze so you make a fence and stop. Keep making peace lilies when you are almost dead and eating anti bb pills. Misty and I did not go far enough as one person found the city but due to the walls could not get in. If we were starting over we would go for maybe a dozen lives in one direction to be almost sure that nobody would ever find it from the outside.
Also, other than the walls make a triple layer of locked doors as the entrance.
You can set your lily petal marker right next to the walls so that you are born outside the walls half the time and inside half the time. The three keys can be hidden outside the walls so that if you are born outside you can get in and then close the doors, and if you need to keep the doors open and work on the town you can eat a carrot seed.
Finally, when you do allow bbs inside you need to check the whole area and make sure there are no tools or iron inside that can be used to make tools to grief. Make sure there is no peace lily or key left inside and that the stone walls are not crumbled. Some tools are ok like adze but you never have more than 3 tools because when they break ppl can make scrap iron out of them and with 4 non griefer tools breaking and making 2 scrap metal they can make a smithing hammer and an axe and chop down all of your trees. Some thing that works well for bbs to be able to farm and make fires is making a lot of thread to make stone hatchets and hoes bc those cannot be used to grief.
Someone tried to make a wall city but forgot about this and left some iron and tools in and when they broke the bbs used some of the iron to grief.
I hope this helps.