Visually the easiest solution would be to use sprites instead of the tilemap so you could ysort.
I also agree the two tilemap idea is one option. A tilemap for the collision and base of the walls and another tilemap for the top. It wouldn’t quite work for your example images unless the walls were taller though.
Another idea is to mask out the parts of the player behind the walls. To do that you’d put the player on its own layer with “force own texture” then you’d place a bunch of rectangle sprites over the walls, and give those sprites the “destination out” blend. Finally you’d ysort the player with those mask sprites. Enemies and whatever else can be on that layer too. I’m not convinced it’s a better idea. It would work with any size walls but you’d have to go through the trouble of manually placing the mask sprites.
A third option would be to have a second empty tilemap above the player, then every tick look at the tiles the player was on and place tiles on the second tilemap if they should be above the player. You’d need more events to each type of tile but would be fairly straightforward. The main con with this way would be that it only would work with one object.
A more generic variation of the above would be to have a sprite with all the same images as the tilemap tile set and just blindly create a sprite at any tile the player overlaps. Then you’d just ysort with those created sprites. That would trivially support enemies too. It would give the benefits of sorting just sprites while only doing it in places that need it.
There are probably other ideas too.