Here is a possibility which uses foldexpressions:
if !empty(getline(a:lnum)) && a:lnum+1 < line('$') && empty(getline(a:lnum+1))
setl foldenable foldexpr=FoldEmptyLines(v:lnum) foldmethod=expr foldtext=getline(v:foldstart).repeat('\ ',winwidth(0)-len(split(getline(v:foldstart))))
This uses a foldexpression to check every line and decide whether the next line is empty. If it is, it will be marked as being inside of foldlevel 1. If the current line is already empty, use the previous foldlevel, else it isn't in a fold.
If you want to also fold lines, containing of only blanks, you would change the
empty(getline(...)) part to
To decide, how the folded line looks like, it uses the
'foldtext' setting and sets it explicitly to the text of the start of the folded line.
There are two problems with this approach. It will be probably slow for long files and second, you lose syntax highlighting for the folded lines.