Terapagos is not a hard counter to Miraidon, but its most common moveset is a good way to threaten it. Currently Smogon recommends the following:
Terapagos @ Leftovers
Level: 50
Ability: Tera Shell
EVs: 172 HP / 76 Def / 100 SpA / 12 SpD / 148 Spe
IVs: 15 Atk
Tera Type: Stellar
Modest Nature
- Tera Starstorm
- Calm Mind
- Protect
- Earth Power
(There is another recommended set, but in your case I prioritized the one that outputs more damage.)
If you feel like Earth Power isn't doing enough, you don't really have any other options. It is by far Terapagos' most used non-STAB attacking move (Pikalytics); it is better than Ice Beam because it also hits meta Pokemon like Incineroar.