You can do it with a MOSFET, but generally you would use an analog switch IC or transmission gate. The problem with a single MOSFET is that the resistance varies with the signal voltage, eventually cutting off when the signal gets to within a few volts of the gate voltage. Thus, a single MOSFET makes a great current switch (say, feeding into an op-amp virtual ground) where the voltage is nearly constant, but not a very good voltage switch unless you signal is confined to a rather limited range.
A transmission gate solves this problem by having both a P-channel and an N-channel MOSFET in parallel. For voltages close to the negative rail, conduction is via the N-channel device, and for voltages close to the positive rail conduction is via the P-channel device. At mid-rail, both devices conduct.
IC analog switches typically have a higher on resistance than discrete MOSFETs, from a few ohms to a few hundred ohms. The on-resistance also still varies somewhat with the signal level. For this reason it is usually preferred to use them in a configuration that doesn't conduct much current. A classic example is a non-inverting op-amp. The obvious solution is to switch the gain by switching resistors in and out of the feedback path. The clever solution is to use a resistor ladder from the output to ground and use analog switches (often available as 4x1 or 8x1 multiplexers) to connect one of the nodes to the inverting input. In that way, gain does not depend on the on resistance.