Yes it can be done with the Teensy, though there are some things you may need to consider.
Since the Teensy 3.6 has 51 digital pins, you could just hook up each LED to a digital pin and a resistor. Note, you will need to solder some wires to pads underneath the Teensy to get enough pins. Trying to connect 40+ wires, resistors, etc. quickly becomes unwieldy, and error prone. In addition, you will likely run into the 250mA limit the Teensy 3.6 has on the total 3.3v power, depending on the power draw of the lights and how many are on at the same time.
A second approach is to use WS2812B/SK6812 based LEDs (Adafruit calls these neopixels). These lights are a sequence of lights (similar to the lights used on Christmas trees) in that you only need one pin to program the LEDs, plus power and ground. Each successive LED is daisy chained from the previous LED. I.e. to program 40 LEDs, the library first sends the information for the first LED, then the second LED, then the third LED, etc. up to the 40th LED. Each light has 3 values from 0 to 255 for the red, green, and blue colors. So you adjust the color and intensity by adjusting the power levels (i.e. 0/0/0 turns off the light, 255/255/255 turns it on to the brightest amount and the eye registers it as white). You do have to watch the power levels with the LEDs (for example, turning on all 40 LEDs to full power is more power than you can get directly from a Teensy 3.6). There are various in/outs with WS2812B LEDs that show up as you get past just a few LEDs. You can buy WS2812B LEDs in various form factors (strands, circles, matrixes, etc.).
There is APA102 LEDs (Adafruit calls these dotstars) that are similar to the WS2812B's but they have 2 data pins to control the LEDs.
There are other methods (I2C expanders and shift registers), but in general you probably want to look at WS2812B LEDs.