If that is possible, once you have stored the Raycast information you can use SendMessage("nombre_funcion")
to execute a function that is in the Script of the object with which you have collided. Be careful, you will have to check first that the object with which your Raycast has collided is the object that contains that function you want to call, since otherwise it will send you an Exception.
If you share the code where you implement your Raycast2D, I could give you a more concrete example, but here is an example of general use:
//Al hacer click primario instanciamos un Raycast2D
if(Input.GetKey(KeyCode.Mouse0)){
//La información del collider que ha entrado en colisión con el Raycast2D se almacena en la variable hit
RaycastHit2D hit = Physics2D.Raycast(transform.position , Vector2.right);
//Si el Raycast2D colisiona con un gameobject cuyo Tag sea Enemigo, llamamos a una función que se encuentra dentro de su Script
if (hit != null && hit.transform.gameObject.tag == "Enemigo"){
hit.transform.gameObject.SendMessage("cambiar_color");
}
}