I also needed this functionality but in an environment without Python nor additional downloadable tools.
I ended up with the following solution using awk only.
cat myfile.md |awk '{if ($0~/^## /) {++count} if (count>1) {exit} print $0}'
It will stop printing lines after the second ## header 2 is found.