You can do that developing a custom extension. As far as I know, there is no way to configure mandatory fields from the UI.
How to create an extension here or you can use use civix.
In your extension, in the main extension's .php file, you can use civicrm hooks, in this case:
hook_civicrm_validateForm( $formName, &$fields, &$files, &$form, &$errors )
For your example, let's say I create my extension as org.civicrm.myextension.
In myextension.php add this for making First Name mandatory:
function myextension_civicrm_validateForm( $formName, &$fields, &$files, &$form, &$errors ){
if ( $formName == 'CRM_Contact_Form_Contact' ) {
// ensure that first name is not empty
$first_name = CRM_Utils_Array::value( 'first_name', $fields );
if ( empty($first_name) ) {
$errors['first_name'] = ts( 'First Name is a required field' );
}
}
return;
}