In term of final result both are same.
First one is pointer is got initialized (assigned an initial value) at the time of declaration.
Second one is declaration then separately initialized to the memory location given by malloc().
float *ptr = malloc(sizeof(*ptr)); is nothing but
float *ptr (declaration) and (ptr = malloc(sizeof(*ptr)) ) (initialization)
It definitely not, what you are thinking.
ptr is of type (float *) which is a pointer.
*ptr is of type (float) which is not a pointer, so it can't points to the address given by malloc()
You can consider your first statement like this:
float * ptr = malloc(sizeof(*ptr); // I think this will clear your doubt.