Using Raspberry Pi GPIO for matrix switching
The easy solution is to use two analog 1:8 multiplexer chips. Connect both 8-sides to your 7 matrix pint (leaving one input unconnected), and the two 1-sides together. Now you can use the two 3-bit address\es to specify the two pins that must be conneced.

A much more difficult but no-components solution is depends on figuring out how the matric is used, presumably 3 or 4 pins are outputs from the controlling device, and the others are inputs. Use your GPIOs to sense what is output, and put the pattern that corresponds to the key you want pressed on the inputs (=your outputs). You must do this faster than the controlling device scans the keys.