The PWM signal is open drain/collector; I recommend using a BSS138 or NX138AKR N-channel enhancement mode logic level MOSFET, with source to ground, drain to the fourth pin of the 4-pin fan connector (MOLEX 47053-1000), and gate to a 100Ω – 220Ω current limiting resistor which is connected to a Teensy GPIO pin. The standard frequency is 25 kHz, but anything between 21 kHz and 29 kHz will work the same.
The tachometer signal (third pin) is also an open drain/collector signal, which the fan controller side should pull to 12V via a pull-up resistor. The circuit I recommend uses a 10kΩ pull-up to 12V, then to the gate of another BSS138 or NX138AKR. The source is connected to ground, and the drain both to a GPIO pin, as well as a a 10kΩ pull-up resistor to 3.3V. You will get two pulses per rotation; at 1200 RPM (typical for quiet 120mm and 140mm fans) it will be 20 pulses per second. You can use an interrupt for this, and the ARM DWT cycle counter to determine the interval between pulses. There will be jitter, so apply a low-pass filter (for example, a box-averaging or an exponential filter).
I prefer NX138AKR in SOT23-3, because it is small, but hand-solderable (two pins at 1.8mm distance, with the third pin on the opposite side centered), and quite cheap at e.g. Mouser and elsewhere; it is also slightly faster than BSS138 to switch because its total gate capacitance is lower.
Connecting the PWM and tach signals this way is quite safe, because these logic-level MOSFETs can handle gate-source voltages between -20V and +20V. MOSFET gates act like capacitors, and the voltage between gate and source (Vgs) determines the resistance between drain and source; NX138AKR works fine down to 2.5V gate voltage (with respect to source - here, ground). It is very rare for MOSFETs to short gate to drain, which is the only way Teensy GPIO pins could be damaged by this.
Except for the wire colors, basically all 4-pin 12V PWM fans follow the
Intel 4-wire PWM fan specification (PDF).