Good day!
I just discovered that Github supports collapsible content in Markdown files via the following HTML5 element:
<details>
<summary>A header for your collapsible content</summary>
Code example:
...
...
... (or use the backticks, whatever works)
Some more markdown content.
</details>
The details sections do not collapse on all browsers, but most I tested with.
Happy coding!