Does the prefab already have a collider? If so you just need to mark the collider as a trigger. Then in a script on that same object you can use “OnTriggerEnter()”, “OnTriggerStay()” and “OnTriggerExit()” for any functionality when something enters the trigger.
If you want to add the collider to a particular instance of a prefab at run-time you can use the AddComponent function and set the collider as a trigger. E.g:
class Example : MonoBehaviour
{
public GameObject prefab;
void Awake()
{
SphereCollider sphere = prefab.AddComponent<SphereCollider>();
sphere.isTrigger = true;
}
void OnTriggerEnter(Collider other)
{
// do something
}
}
AddComponent function: Unity - Scripting API: GameObject.AddComponent