(Maybe a little late for this answer) I have the same situation as you, I have three sections contained in the same TOC tree:
- Equipment
- Software
- Study guides
I tried to achieve the same thing as you, which hides everything for my sidebar menu that does not apply to the current toctree-l1. Knowing that Sphinx is adding the "current" CSS class, I came up with:
#sidebar li.toctree-l1:not(.current){ display: none; }
This is not the best solution ever, but since Sphinx can just process one main root for documentation and from it it creates the whole TOC tree, if you need it only for the sidebar menu, CSS may work for you.
Screenshot of my menu showing the content below one section:

source share