Well you have three main options in my opinion.
Bonds/Fixed Term Deposits
For cash, or any assets you can convert to cash, you could purchase bonds with a maturity date close to what you are looking to lock your funds up for. While you could sell these on a secondary market, admittedly - however you have a justification you can provide to yourself as to why you cannot sell them.
Fixed term deposits often have poor interest rates, but if you ask to withdraw your money early you often forfeit all of the interest you would have gained.
Equity Investments
While your money would not be locked up, it keeps it further out of your reach, just like bonds. Every step further away from your bank account the funds get, the less likely you are to surrender to giving away money that is rightfully yours.
It comes with the added advantage of typically high-returns.
Trust Fund
Trust funds can be set up with anyone as the beneficiary, and provide legal barriers so long as the beneficiary isn't also the executor. While it can be expensive to do so, you could hire a lawyer who specialises in estate law to set up a trust fund you are the beneficiary of, which has stipulations as to how and when assets can be released.
Others
I didn't include this as one of the main three, because it doesn't allow you to specify exactly when funds are released to you, but in many countries (including the US) you have special tax advantaged retirement accounts, where funds are locked away until you retire.
However, it is unfortunate you even need to think about this. Another thing to consider is that if people start pressuring you for money, you should cut them out of your life.