My current idea is just to have the leg basically fold into itself but I'm unsure how sturdy this would be.
You can get around the obvious strength concern of a leg that folds in the centre by using bracing, but I think there are better ways to go about this as covered by the links below.
In addition to using fewer hinges there are a few existing designs that don't rely on them at all — instead of folding, the legs/leg assemblies slot into the underside of the top. This has the advantage of not having to fit hinges, but the disadvantage that the table isn't a single unit which stays connected (with the possibility of losing one or more legs somewhere down the line).
The first thing I thought of when I read the Question title was folding or collapsible workbenches since I collected many of these early on as I searched for my ideal workbench design. And the first of those that came to mind was the Apartment Workbench:
Apartment Workbench on Close Grain blog.
There's also this collapsible workbench on Instructables:
Collapsible Workbench on Instructables.
The above may not look like much but the design is a paragon of simplicity, and I think this lends itself to most easily being adaptable to variations in materials and proportion.
In case you want to prioritise ruggedness and aesthetics matter less I'm also including this heavy-duty work table on the Popular Woodworking site:
There are a few other fold-up benches made from ply or OSB that are broadly similar to Tom Caspar's above including this one posted by Woodsmith on their YouTube channel only 10 days ago.