Custom post class, generate unique id from 1 to x depending on amount of posts?

Just take the post ID. It’s already unique.

// In the loop
printf(
    "<tag>%s-{$post->post_title}</tag>",
    get_the_ID()
);

If you need it to go from 1-x, where it has to start with 1, then simply use:

// In the Loop:
// Assign "1" only to the first post
0 === $post->current_post AND $id = 1;

Then just go and build an array of integers before the Loop:

// An array of integers that have the range starting from 2 
// until the max amount of posts reduced by 1 for the first post
$id_array = range( 2, $GLOBALS['wp_query']->post_count -1 );

With array_rand() you’ll be able to retrieve some sort of random key from it.

// Before the Loop
$rand_keys = array_rand( $id_array, count( $id_array ) );

// In the Loop
$id = 0 !== $post->current_post ? $id_array[ $rand_keys[ $post->current_post ] ] : 1;
printf(
    "<tag>%s-{$post->post_title}</tag>",
    $id
);

You could as well use shuffle() to mix the range() result.