Refusing to be served legal papers is not illegal in itself but if you're being served a summons to appear in court then refusing that summons could mean that you get a warrant out for your arrest for failure to appear in court.
But if it's just other legal papers then you won't be arrested.
Still though the process server will try to serve you with the legal papers a few times and then if you still refuse to be served the papers the information that you're being served with may be published online or in a newspaper to serve you and that can then be seen as serving you legally.
The best thing to do is just accept the papers being served to you and get on with your life.
Court papers can be sent through mail but must go through certified mail where you have to sign for those papers.
If you refuse to sign for those papers and it's a court summons then you will either have a warrant out for your arrest for not appearing in court.
Or they will send a sheriff out to your door to serve the court papers in person.
In some states a sheriff or other process server will serve a summons to you to appear in court or serve other court documents to be sure you got the papers and signed for them.
Some places may try the US mail first and then if you refuse them then they will send a process server or sheriff out to serve the papers.
You can refuse to sign the court papers but if it's a summons to appear in court then the court will just put a warrant out for your arrest.
So always accept the court papers that are served to you and show up at court when needed as it makes it easier on you.