It is possible to hide activities based on values in user profile fields using Access restrictions for the activity. (enable Restricted Access under Advanced features)
Course completion based on activities is only on completing all of the selected activities or any so this won't work as different activities are required for a person to complete a course. You can make the course completion based on a course grade so if you gave the optional activities the same grade value then you could make course completion based on a required course grade sum of mandatory and optional activities.
There may also be some changes to the gradebook where grades for optional activities can be grouped into categories and aggregated differently such as highest optional activity. See https://help.totaralearning.com/display/TL29/Grading for an explanation of the different grading options