Get caught committing a minor infraction in a settlement and get caught, choose to go to jail and figure out how to escape depending on the particular jail you get placed in. Simply stealing an item in front of another NPC should be enough.
I got caught in the goblin camp, to escape from the goblin jail interact with the dead person sticking out of the wall to pull them out, next damage the portion of wall they came from until it breaks and you can escape through the hole. Your weapons will be confiscated but casters can attack the wall with cantrips/spells and non casters can use improvised weapons or unarmed attacks to break the wall.