The question flagged by berendi shows you what will work, but does not fully cover some relevant aspects.
As shown the simple circuit (pin connected to LED to ground and resistor to V+ > Vdd) is potentially liable to cause incorrect system operation and in some cases to damage the uC (microcontroller).
Adding a transistor to drive the LED, as shown in that Q&A set, greatly increases the flexibility available - LED current can be higher and load voltage is independent of uC capability.
Using the pin as shown will work for LEDs with Vf lower than uC_Vdd. However:
If the LED has a Vf of say 3V3 then the pin will be pulled to 3V3 when the pin is turned off - this will quite possibly cause system malfunction if Vdd is 3V.
I_LED_max permissible is the current that the uC pin can pull down to below the LEDs on voltage - say < 1.5V for a white LED and well under 1V for a red or IR LED. This may be quite low, depending on the pin drive capability.
As shown ILed is about (5V-Vled)/10k = about 0.2 mA for a Vf~=3V white LED and 0.3 mA for Vf ~= 2V a red LED. At those current levels, with typical LEDs you'll get light but it won't be bright.
SO this arrangement CAN work for some values of "can" but adding a transistor gives MUCH better control and flexibility.
The diagram below is from StevenH's answer to the 2012 question.
The LED supply voltage is shown as 3V3 but can be higher than Vdd subject to design of R2 and R3 values so that Vpin is never > Vdd when the pin is off/open-circuit and that Q2 received enough dreive when the pin is low.
As shown a bipolar transistor is used but a P channel FET would make design slightly easier.
The circuit below (from the 2012 question) would work as is with a standard (push-pull / high low) pin drive, or with an open drain pin if R32 was replaced with a wire and a suitable pullup resistor was added from transistor base to uC Vdd.
This circuit reverses the polarity of pin level and LED state. eg
Original - pin low = LED on.
With transistor - pin high = LED on.