In general, it’s a gimmick plain and simple. However, if your primary goal is to see improved lung function then it may have something to offer you. Consider the following.
Let’s say you can run a mile in 10 minutes while wearing the thing. Also, without wearing the thing you can run a mile in 6 minutes. Which do you suppose was the more challenging and effective workout? The one that had you utilizing your body to it’s fullest of course.
However, those masks are still gimmicky beyond even that. ElevationThe elevation aspect of these masks do not work because your body needs to adapt to a new elevation over the course of multiple weeks. Training for 1-2 hours a day does not replicate the same need for adaptation as actually living somewhere with high elevation. Secondly, training with those masks will limit the total airflow you can have, meaning that you have to work harder in order to breathe. That's not how elevation works. In high elevation, the oxygen concentration is much less and so you still take the same breathes, you just have less oxygen concentration. Here's an an analogy to show the difference: you can a cup of orange juice. Training with an oxygen mask is like using a very tiny straw to drink the juice (like a coffee straw). You have to suck really hard to get a little juice. Real elevation is like mixing the cup of OJ with water, diluting the OJ. You don't have to work any harder to drink the OJ, but you get less OJ with each sip.
This video that explores the topic a bit more.
As mentioned though, these masks can improve lung function if that is your primary goal. At least one study affirms this, but keep in mind that it does not simulate altitude and nothing was mentioned about how athletic performance was impacted beyond improved lung functionality. I would advise caution if you have breathing related problems, but if your lungs are healthy and you would like to breath better, this type of product can indeed strengthen the lungs.