Create a private exam
Access to exams can be controlled using the access control setting. If you want to restrict access to the exam to specific users, you can add users to a particular batch and assign that batch to this exam.
Now inside the exam settings page, select Private in Access Control. You can add the batches in the Batch dropdown.
Click submit once you are done. Only members present inside the batch will be able to attend the exam.