Basically you can add an invisible, gravity-defying armorstand in the game with a text property, like this:
/summon armor_stand ~ ~ ~ {Invulnerable:1b,NoGravity:1b,Invisible:1b,CustomNameVisible:1b,CustomName:THE FLOATING TEXT SAYS HI}
You can also remove the floating text by either doing:
/minecraft:kill @e[type=armor_stand,c=1]
c stands for the count flag, so it will stop killing armor stands when it kills one. This command essentially removes the nearest invisible armor stand.
/summon armor_stand ~ ~ ~ {Invulnerable:1b,NoGravity:1b,Invisible:1b,CustomNameVisible:1b,CustomName:THE FLOATING TEXT SAYS HI}
You can also remove the floating text by either doing:
/minecraft:kill @e[type=armor_stand,c=1]
c stands for the count flag, so it will stop killing armor stands when it kills one. This command essentially removes the nearest invisible armor stand.