You are asking for a definition of BIC for lasso. This is not really a MATLAB question. You might have better luck posting it to sci.stat.math or a similar group.
I am not an expert. For what it's worth, using residuals instead of residuals squared looks odd to me too. (But I don't see a problem with lasso documentation; it's a problem with your definition of BIC.) Two other things look odd to me as well: Including the lasso penalty in the variance term and using the number of all predictors in the model as the number of degrees of freedom. A quick Google search finds this paper:
Their definition of BIC for lasso looks nothing like yours.
