Can I select an object in the hierarchy with code while the game is running?

I have to select an instantiated gameobject with the mouse but the game is running. The mouse needs to stay in a certain place in the game for navigation and player position

Assuming you are talking about inside the Unity Editor, then yes you can. Example script that select the object it is attached to when the space bar is hit:

#pragma strict

import UnityEditor;

function Update() {
	if (Input.GetKeyDown(KeyCode.Space)) {
		Selection.activeObject = gameObject;
	}
}