Is there a tool like a ratchet clamp but for pushing?
The comment is correct but there is an answer.

Measure accurately the length between the pressed in wood support and the opposite wall. Cut a 2X4 to this length Minus half an inch or so. With some paper or such on the wall opposite to protect the paint put the 2X4 against the shelf support and add more wood to shim it into place. Shims are sold as very thin wood wedges and it would take several of those. That might be tough to manage. Once you see the goal as I describe it the solution will be seen within the pieces you have.