I guess you could just add this to the php file, I didn’t test it though.
<script>
jQuery(document).ready(function($){
jQuery('#pass2').removeAttr('id');
if ( 'preferences' == section ) {
jQuery('#pass1, #pass2, #pass1-text').prop('disabled', false);
} else {
jQuery('#pass1, #pass2, #pass1-text').prop('disabled', true);
}
});
</script>