Updated:

1. Invisible item frame (1.20.5+)

/give @p item_frame[entity_data={id:"minecraft:item_frame",Invisible:1b}] 16
/give @p glow_item_frame[entity_data={id:"minecraft:glow_item_frame",Invisible:1b}] 16

Only the item inside is visible, so it looks like it floats on the wall. On 1.20.4 and earlier use item_frame{EntityTag:{Invisible:1b}}.

2. Fixed frame

/give @p item_frame[entity_data={id:"minecraft:item_frame",Fixed:1b}] 16

Fixed:1b stops the frame breaking and stops players taking or rotating the item. You cannot put an item into a fixed frame, so use the next method for filled frames.

3. Summon a frame with an item

/summon item_frame ~ ~1 ~ {Facing:1b,Fixed:1b,Invisible:1b,Item:{id:"minecraft:diamond_sword",count:1}}
FacingDirection
0Down (ceiling)
1Up (floor)
2North
3South
4West
5East

On 1.20.4 and earlier write Count:1b instead of count:1.

4. Change a placed frame

/data merge entity @e[type=item_frame,limit=1,sort=nearest] {Fixed:1b,Invisible:1b}
/data merge entity @e[type=item_frame,limit=1,sort=nearest] {ItemRotation:2b}

Place a normal frame, add the item and set the angle by hand, then lock it. ItemRotation goes from 0 to 7 in 45 degree steps. See the data command.

5. Rotation puzzle (Java)

/summon item_frame ~ ~1 ~ {Facing:1b,Tags:["lock1"],Item:{id:"minecraft:arrow",count:1}}
# Repeating command block
execute if entity @e[type=item_frame,tag=lock1,nbt={ItemRotation:2b}] run setblock 10 64 10 minecraft:redstone_block

Players right-click to turn the arrow. When it reaches ItemRotation:2b, a redstone block appears at 10 64 10 and opens a door. Leave out Fixed so the frame can turn. Use three frames with different tags for a dial lock. See the escape room commands.

Troubleshooting

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.