This function can be called in a cell by =FormatURLsToMD(A1) where A1 is a cell reference or =FormatURLsToMD("http://www.linux-magazin.de/NEWS/Debian-Gruender-Ian-Murdock-ist-tot").

I am not an LibreOffice Basic expert. This is my solution to my problem. If you know a more elegant solution, please let me know.

JavaScript/Python alternative

LibreOffice can execute JavaScript and Python scripts. However, such functions cannot be called directly from a spreadsheet. Thus, a Basic function wrapper must be created. This solution could be preferable for more complex functions to circumvent the Basic language limitations.