This doesn’t exactly answer your question but you can use vim to do this. Obsidian has a vim mode but it doesn’t seem to support these commands, which is quite unfortunate.
Here’s an example:
# Important Note
Text 1
Text 2
Text 3
You can run:
:g/^$/d
to get
# Important Note
Text 1
Text 2
Text 3
Or
:%s/\n\{3,}/\r\r/e
to get
# Important Note
Text 1
Text 2
Text 3
If someone knows how to make these commands work in CodeMirror’s vim mode, please let me know.