Japt v2.0a0, 30 29 28 bytes
Takes input in lowercase, prepend v<space>
for +2 bytes if that's not allowed.
óÍ®n îZèÍg"- ="òìyÈû4 Ôû6'_
I'll have to come back later and add a separate section explaining how the partition works as it's a difficult one - I'm not sure I fully understand it myself yet! I'll also add some more detail on why Í="n"
.
óÍ®n îZèÍg"- ="òìyÈû4 Ôû6'_ :Implicit input of string
óÍ :Partition into the groups we need
® :Map each Z
n : Convert to integer (the letter at the end is ignored)
î : Repeat and slice to that length
Zè : Count the occurrences in Z of
Í : "n"
g : Index into
"- ="ò : Partitions of "- =" of length 2
à :End map
¬ :Join
y :Transpose
È :Pass each row through the following function and transpose back
û4 : Centre pad with spaces to length 4
Ô : Reverse ('cause centre padding is right-biased)
û6'_ : Centre pad with "_" to length 6