Can the user define a macro in Mathematica language?
if you're trying to make a traditional macro, you would implement it as a function with the HoldFirst et al attribute.
an important thing to know is that ReplaceAll uses arbitrary structural patterns. it's not a simple "turn every a into b". you can say things like "turn every application of the symbol F on an even number into an application of G on that number divided by two".
expr /. F[n_?EvenQ] :> G[n/2]
[1] https://reference.wolfram.com/language/ref/ReplaceAll.html