You don't give an exact jurisdiction, so Im going to give some examples from the US and the UK here (other jurisdictions may differ), but the answer to your question seems to be "yes, you can" in the US and UK.
In the US, the process differs somewhat between states, but in general you need to file a written, signed (and notorized in some states) disclaimer with the executor of the estate or probate court within a reasonable timeframe.
To disclaim an inheritance, you must file a written disclaimer that states your irrevocable intention to refuse the bequest. A disclaimer usually must be signed, notarized, and filed with the probate court and/or the executor of the last will in a timely manner (within nine months of the death of the decedent or, if the disclaiming beneficiary is a minor, after he or she reaches the age of majority).
https://www.legalzoom.com/articles/how-to-refuse-an-inheritance
In the UK, you can file either a variation or a disclaimer depending on the situation:
There are two methods of refusing an inheritance: variations and disclaimers. To be effective for tax purposes, both must be in writing and executed within two years of the date of death (although a disclaimer can be effective to refuse a gift, even if it is made by the conduct of the beneficiary, rather than in writing).
https://www.thegazette.co.uk/all-notices/content/101535
After rereading the question and some of the comments, I note that you are asking a mixture of questions - the above answers the "do I have to take responsibility for something someone left me in a will" question, but you also seem to want to know whether you can do this proactively.
Unfortunately, in most jurisdictions, wills and bequests do not need to be made public until they are executed, so someone can put anything they like into a will and you won't know about it until their death (or at any other point the will becomes public).
Restraining orders et al won't work in this regard, as the subject will be dead and thus cannot be punished for breaching the order.
Your best course of action is to legally disclaim the bequest once it becomes your responsibility - if you do this, you are protected from any negative consequences (taxation, ownership et al) of receiving the inheritance.