Float and Rotate for an Instantiated object

I’m attempting to add float and rotate to an object I have instantiated around a player. Being new to unity, I’m not sure if this would have to be implemented in a new script that would be applied to the prefab of the object, or if this needs to be part of the Instantiate function. So far, I couldn’t get it to work a separate script.

The code I’m looking to implement, I would imagine is something close to this:

        transform.Rotate(Vector3.up, rotateSpeed * Time.deltaTime);
        Vector3 tempPos = startPos;
        tempPos.y += Mathf.Sin(Time.fixedTime * Mathf.PI * floatFrequency) *
            floatAmplitude;

Here is the Instantiate function:
private void InstantiateKey()

  private void InstantiateKey()
    {
        int index = Random.Range(0, availableKeys.Length);
        float x = player.transform.position.x + GenerateRange();
        float y = player.transform.position.y + 1;
        float z = player.transform.position.z + GenerateRange();

        Instantiate(availableKeys[index], new Vector3(x, y, z), Quaternion.Euler(90, 0, 0));

I’m just not quite sure how to have this action associate with each of the chosen objects that are generated.

This should be in a script attached to the prefab object. Instantiate has no control over an object once it is created, only the starting position and rotation, and movement thereafter should be done in a script attached to the spawned object. This script should do it -

public class KeyRotateAndFloat : Monobehavior {
    public float rotateSpeed;
    public float floatFrequency, floatAmplitude;
    public Vector3 startPos;

    void Awake(){
        startPos = transform.position;
    }

    void Update(){
        //Make sure you are using the right parameters here
        transform.Rotate(0, rotateSpeed * Time.deltaTime, 0);

        Vector3 tempPos = startPos;
        tempPos.y += Mathf.Sin(Time.fixedTime * Mathf.PI * floatFrequency) * floatAmplitude;

        transform.position = tempPos;
    }
}