Measure the interior dimensions of the pocket in your existing floating shelf. This is easier if you measure the exterior dimensions of the whole shelf, then subtract the visible width of the shelf panels.
Cut two wood strips to match the width of your shelf, using a power saw. Cut two more strips to match the depth, minus 1 inch.
Use a planar to shave height off the lumber you've cut until it matches the height of the interior pocket of your floating shelf.
Set the strips into a rectangular frame, with the ends of the depth-cut strips abutting the interior faces of the width-cut strips. Glue them together with a smear of wood glue, holding them in place with clamps as they dry.
Reinforce the connection of each strip using a 1-inch wood screw. Predrill pilot holes, using a power drill, to avoid splitting the wood.
Insert the finished frame into your existing floating shelf to test the fit. You may need to sand or plane down the shelf to fine-tune the fit.