Adding a ‘featured’ class to certain posts

WordPress by default provides such feature named “Sticky Posts”. you can mark any post as sticky from “Quick Edit” link. and WordPress will add a post class named sticky with all sticky posts. so you can use this class in your CSS for giving custom styles.

and another solutions is to create custom post meta and meta boxes in wp-admin. and provide your users a way to mark any post as “Featured”. and then based on that meta field value you can easily alter the post class.

find more info about Meta Box and Custom fields from WordPress Codex.
and then if you have added a custom field in a post named “featured_post” you can alter the post class using below function. it will add a class named ‘featured-post‘ with all posts marked as featured.

add_action( 'load-post.php', 'annframe_meta_boxes_setup' );
add_action( 'load-post-new.php', 'annframe_meta_boxes_setup' );
add_action( 'save_post', 'annframe_save_post_meta', 10, 2 );

function annframe_meta_boxes_setup() {
  add_action( 'add_meta_boxes', 'annframe_add_meta_box' );
}

function annframe_add_meta_box() {
  add_meta_box(
      'featured_post',                    // Unique ID
      __( 'Featured Post' ),    // Title
      'annframe_display_meta_box',        // Callback function
      'post',  // Admin page (or post type)
      'side',    // Context
      'high'
    );
}

function annframe_display_meta_box( $post ) {
  wp_nonce_field( basename( __FILE__ ), 'ann_meta_boxes_nonce' );
  ?>
   <label for="meta-box-checkbox"><?php _e( 'Mark as featured'); ?></label>
   <input type="checkbox" id="meta-box-checkbox"  name="meta-box-checkbox" value="yes" <?php if ( get_post_meta( $post->ID, 'featured_post', true ) == 'yes' ) echo ' checked="checked"'; ?>>
  <?php
}

// Save meta value.
function annframe_save_post_meta( $post_id, $post ) {

  /* Verify the nonce before proceeding. */
  if ( !isset( $_POST['ann_meta_boxes_nonce'] ) || !wp_verify_nonce( $_POST['ann_meta_boxes_nonce'], basename( __FILE__ ) ) )
    return $post_id;

  /* Get the post type object. */
  $post_type = get_post_type_object( $post->post_type );

  /* Check if the current user has permission to edit the post. */
  if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
    return $post_id;

  $meta_box_checkbox_value="";
  if( isset( $_POST["meta-box-checkbox"] ) ) {
    $meta_box_checkbox_value = $_POST["meta-box-checkbox"];
  }

  update_post_meta( $post_id, "featured_post", $meta_box_checkbox_value );
}

// add class.
function annframe_featured_class( $classes ) {
global $post;
if ( get_post_meta( $post->ID, 'featured_post' ) &&  get_post_meta( $post->ID, 'featured_post', true ) == 'yes' ) {
$classes[] = 'featured-post';
}
return $classes;
}
add_filter( 'post_class', 'annframe_featured_class' );