In principle yes, if the life insurance policy provides for a contractually guaranteed minimum benefit. The mortgage lender (insurance company, bank, etc.) will then consider to what extent it will accept that benefit as collateral.
You are on the safe side if you have a life insurance policy with a fixed, contractually guaranteed benefit at maturity. If this life insurance is taken out in Pillar 3a, the mortgage principal secured by the policy is repaid indirectly. This means that the principal amount is first accrued through the life insurance policy and not paid out to the mortgage lender until the agreed date. You thus take advantage of Pillar 3a tax benefits throughout the contract term.