How to modify query on category pages to show only sticky posts?

Just set ‘post__in’ to a null array.

add_action( 'pre_get_posts', function( \WP_Query $q ) {
if( ! is_admin() && $q->is_category() && $q->is_main_query() ) {
    $sticky_posts = get_option( 'sticky_posts' );
    //If there are sticky posts
    if( ! empty( $sticky_posts ) ) {
        $q->set( 'post__in', (array) $sticky_posts );
    }
    //If not
    else {
        $q->set( 'post__in', array(0) );
    }
}
} );