Identify what your recipe is doing: gratin/au gratin browning, sandwich melt, or a fondue-style smooth melt.
Pick the substitute that matches the job: for closest gruyere-like melt and flavor, choose Emmental + a small amount of cream cheese or Fontina.
Use the 1:1 ratio for single-cheese swaps; for mixed swaps (cheddar + mozzarella), measure using the split ratio.
If you need more browning than the substitute provides, bake/grill a few minutes longer or briefly broil at the end.
Taste and adjust seasoning (especially salt/pepper) because many swaps are milder or sharper than gruyere.