I have named the collections as coll1 and coll2 then just use this query it will give you the required output.
db.getCollection('coll1').aggregate([
    {
        $facet: {
            commonRecords: [{
                    $lookup: {
                        from: "coll2",
                        localField: 'name',
                        foreignField: 'name',
                        as: "coll2"
                    }
                },
                {
                    $unwind: {
                        path: '$coll2',
                        preserveNullAndEmptyArrays: true
                    }
                }
            ]
        }
    },
    {
        $lookup: {
            from: "coll2",
            let: {
                names: {
                    $map: {
                        input: '$commonRecords',
                        as: 'commonRecord',
                        in: '$$commonRecord.name'
                    }
                }
            },
            pipeline: [{
                $match: {
                    $expr: {
                        $eq: [{
                            $indexOfArray: ['$$names', '$name']
                        }, -1]
                    }
                }
            }, ],
            as: "coll2"
        }
    },
    {
        $addFields: {
            coll2: {
                $map: {
                    input: '$coll2',
                    as: 'doc',
                    in: {
                        coll2: '$$doc'
                    }
                }
            }
        }
    },
    {
        $project: {
            records: {
                $concatArrays: ['$commonRecords', '$coll2']
            }
        }
    },
    {
        $unwind: '$records'
    },
    {
        $replaceRoot: {
            newRoot: '$records'
        }
    },
    {
        $project: {
            _id: 0,
            name: {
                $ifNull: ['$name', '$coll2.name']
            },
            marks1: {
                $ifNull: ['$marks', 0]
            },
            marks2: {
                $ifNull: ['$coll2.marks', 0]
            }
        }
    },
    {
        $addFields: {
            result: {
                $add: ['$marks1', '$marks2']
            }
        }
    }
])