I coded mine to close the mirrors on locking with Carly some time ago. I now have BimmerCode as well so I looked into it.
The coding requires fold on comfort closing, but BimmerCode doesn't offer the second necessary coding which is to set the closing delay time to 0.0 sec.
From the old Carly coding guide (I pulled it off Wayback. They no longer list all the options on the web site - you have to go through the app.):
Comfort close – door (comfort access)
• on
• off
Use comfort closing features when locking with the door handle. This only works if comfort access is installed. Touch the locking area on the door handle for a longer time to close all windows and the sunroof. (codable in CAS)
Comfort folding for sideview mirrors
• on
• off
When holding the lock/unlock button on the remote the sideview mirrors automatically fold/unfold. To activate this function please activate ‘Comfort folding/unfolding for sideview mirrors’ in the ‘FRM’ module. Also activate ‘Comfort open using remote’ and ‘Comfort close using remote’ in this module. (codable in CAS)
Comfort closing delay (mirrors)
• 0.0s
• 0.5s
• 1.5s
General delay for comfort closing. If ‘0.0s’ is set, mirrors fold immediately when car is locked. (codable in CAS)
I expect you could do it in BimmerCode expert mode but I don't have any experience with it.
Gerry