Multiplexing L298N motor drivers
Is it okay to multiplex these drivers with pulling all the GNDs HIGH

No! According to the L298 datasheet, input pins must not go more than 0.3 V below ground. Another possible problem is that each motor driver would need its own fully isolated power supply to keep the grounds separate.
If the motor drivers had opto-coupled inputs then you could do it, because the optocoupler provides the required isolation and its input is an LED that only lights up with one polarity. Some L298 motor driver boards have optocouplers built in, but they usually connect them all to a common supply rail so you can't multiplex more that one input independently.
You could add external optocouplers like this:-



simulate this circuit &ndash; Schematic created using CircuitLab

Is it a preferred method of doing it or should I choose another
method?

Using a matrix of optocouplers has the advantage of keeping controller ground noise (caused by high motor current) away from sensitive parts of the circuit such as the MCU.
Another method would be to use 1-of-n decoder ICs to convert binary to single outputs, eg. 74HC4514 (you need two of them because each IC only has 16 outputs). This would free up several I/O pins because you only need 5 or 6 pins to control two 1 of 16 decoders. On the minus side you would have to be more careful with routing of ground wires to the motor controllers.
Or you could shift registers such as the 74HC595 (3 required), or an I/O expander IC.