This kind of function is frequently ask by developer. Unfortunately the shortcut function to Collapse All or Toggle All is not available on the SSMS until now. I found the same question on the stack overflow since 9 years ago. For alternative developer can Collapse all by going to Edit >> Outlining >> Toggle All Outlining
Source : Stackoverflow