If I have the table
SELECT (Firstname || \'-\' || Middlename || \'-\' || Surname) AS example_column
FROM example_table
This will
This may be a viable option:
SELECT FirstName || '-' || ISNULL(MiddleName + '-', '') || Surname
Since a NULL concatenated with a string yields a NULL, we can attempt to build our sub-string and replace a NULL with an empty string, which is then concatenated to the next part of the name.
This assumes that FirstName and Surname are always NOT NULL, but you could apply the same logic to then as well.