For the sake of completeness, I'd like to mention the plugin-based option.
If you use something like ALE which supports running your buffers through a beautifier on save, you could let Prettier handle rewrapping your code.
I accomplished that by putting this in ~/.vim/ftplugin/markdown.vim:
let b:ale_fixers = ['prettier', 'remove_trailing_lines', '...
It would be really hard to do reliably.
Basically, if you brave enough, check what current markdown plugin uses for folding and try to rewrite it:
:set foldmethod? to find out if it is expr or not
:set foldexpr? to find out what is the function name expr uses
create your own MarkdownFold() function (or whatever name is 2. showed)
So you would end up copy ...