This is a so-called "invalid state", because the sign is not meant to be there in a normal situation. So you have to use tricks to get it there and then be careful to not change anything on any of the six adjacent blocks ever again.

**With commands**, you can just use `/setblock`, because it doesn't update the block. But you have to specify everything about the sign. The one in your example can be set like this:

    /setblock ~ ~ ~ wall_sign 0 {Text1:"",Text2:"This is a",Text3:"floating sign",Text4:""}

You  have to replace the 0 with a number from 0 to 3, depending on the direction of the sign.  
You may have to have all four "Text" tags for it to work. The wiki says that, but I didn't test it.

**Without commands**, you always have to abuse bugs. Those can break in any version, so this is one example for 1.12.2:

Place dirt.  
Place a two blocks high flower above it, for example a sunflower.  
Place the sign on the side of the top block of the flower.  
Break the dirt.  
Result: The plant breaks, but the sign doesn't get updated, so it floats.

This relies on [this bug](https://bugs.mojang.com/browse/MC-31038).