Well you have to detect somehow where walls are. This can be rather tricky.
Your easiest way would be doing this via the levelblueprint and box volumes at every wall where you want to lean against.
You could also do something like actors as wall with a volume and your character can check if one of those is nearby.
There are no functions to stick to a wall, or to get where the next wall is or anything like that. You’ll have to figure a way out to do either.