The MongoDB Node.js driver version 4.7.0 is compatible with MongoDB server versions from 3.6 and higher, which includes MongoDB version 4.2. This means that the driver should be able to communicate with the Cosmos DB instance that is API-compatible with MongoDB 4.2.
MongoDB Node.js Driver 4.7.0 has been tested for compatibility with Node.js versions up to 18 at the time of its release. Node.js version 20 might not be officially supported or tested, which means there could be unexpected issues. However, in many cases, the driver could still work with newer Node.js versions unless there are breaking changes in Node.js that affect the driver.
Azure Functions support Node.js versions, including v20, but compatibility between the MongoDB driver and Node.js in the context of Azure Functions depends on the driver and Node.js versions being compatible.
I recommend that you deploy a sample Azure Function with Node.js v20 and MongoDB Node.js driver v4.7.0 to a staging environment connected to your Cosmos DB instance. This will help you identify any potential issues before moving to production.